English translation
Set random seed for reproducibility
AI Article Decision Snapshot
Turn the lesson into workflow, model, budget, and security checks before choosing tools.
Use this quick snapshot before leaving the article. It keeps the next search tied to practical AI software, model/API, cost, privacy, and implementation questions.
Workflow fit
Identify the real job behind the article: coding, research, document review, support, analytics, content, or internal automation.
Model or tool decision
Decide whether the next step is a software shortlist, an AI tool comparison, an API platform choice, or a model benchmark.
Budget and usage signal
Estimate seats, API calls, prompt volume, retries, review time, and fallback work before assuming the workflow is cheap.
Security and privacy review
Check whether source code, customer data, private documents, prompts, logs, or embeddings will enter the AI workflow.
The Law of Large Numbers tells us that, given a sufficiently large number of repetitions, the sample average will gradually converge toward the theoretical expectation—but it does not guarantee stability in short-term outcomes.
I distinguish between long-term patterns and short-term fluctuations. With small samples, avoid mistaking random variation for genuine underlying patterns.
In the previous article, we explored key concepts in probability theory: expected value, variance, covariance, and correlation. The next topic—central to probability theory—is the Law of Large Numbers, a foundational theorem with both theoretical significance and rich practical implications.
Concept of the Law of Large Numbers
The Law of Large Numbers states that, when conducting a large number of independent and identically distributed (i.i.d.) random experiments, the sample mean converges toward the population’s expected value. Put simply: as the sample size increases, the average of the observed data increasingly approximates the true expected value.
When learning the Law of Large Numbers, first clarify these core elements: independent repeated trials, sample mean, expected value, sample size, and the meaning of “convergence.”
Formal Definition
Let be a sequence of independent and identically distributed random variables, each with finite expected value . According to the Law of Large Numbers, as the sample size , the sample mean converges almost surely to . Mathematically:
Example: Rolling a Fair Die
Consider a simple experiment: rolling a fair six-sided die. Each outcome occurs with equal probability . The expected value is:
By the Law of Large Numbers, if we roll the die many times and compute the running sample mean , this average will approach 3.5 as the number of rolls grows.
Practical Code Example
We can simulate this process using Python:
import numpy as np
import matplotlib.pyplot as plt
# Set random seed for reproducibility
np.random.seed(42)
# Number of die rolls
n = 1000
# Simulate n independent die rolls
dice_rolls = np.random.randint(1, 7, size=n)
# Compute cumulative sample means
sample_means = np.cumsum(dice_rolls) / np.arange(1, n + 1)
# Plot convergence
plt.figure(figsize=(10, 5))
plt.plot(sample_means, label='Sample Mean')
plt.axhline(3.5, color='red', linestyle='--', label='Expected Value (3.5)')
plt.xlabel('Number of Trials')
plt.ylabel('Sample Mean')
plt.title('Convergence of Sample Mean to Expected Value')
plt.legend()
plt.grid()
plt.show()
In this code, we simulate 1000 die rolls and compute the cumulative sample mean after each trial. The resulting plot visually demonstrates how the sample mean progressively approaches 3.5 as the number of trials increases.
After studying “Illustrating the Law of Large Numbers”, try adapting it to a scenario of your own—pay special attention to whether inputs, processing steps, and outputs align coherently.
To apply “Illustrating the Law of Large Numbers” to your own task, start by narrowing the scope: test just one critical decision point first.
Key Takeaways
- The Law of Large Numbers describes how, under repeated i.i.d. sampling, the sample mean converges to the population’s expected value.
- In practice, this principle helps us interpret data stability and generalizability—and remains one of the cornerstones of foundational statistics.
Before reading “Illustrating the Law of Large Numbers”, use the accompanying diagram to confirm the main thread; afterward, revisit it to identify which steps you can execute directly—and which require supplemental background material.
In the next article, we’ll focus on the Central Limit Theorem, exploring its relationship with the Law of Large Numbers and its real-world applications—deepening our understanding of probability theory. Stay tuned!
Apply This Lesson
Turn this article into AI software, model, API, and security decisions.
English Article FAQ
Use this article as evidence before choosing AI tools
How should I use this AI Tutorials article?
Use it as the implementation or learning layer, then connect the idea to AI software buyer guides, tool comparisons, benchmarks, API choices, and security checks before making a production decision.
Is this English article different from the Chinese original?
The English edition is localized for global AI readers while preserving the original diagrams, screenshots, prompts, code examples, and source context from the Chinese article.
What should I read after Set random seed for reproducibility?
Continue with AI Software Buyer Guides, AI Tools Workbench, Best AI Coding Agents, AI Model Benchmarks, OpenAI vs Anthropic API, or LLM Security Tools depending on the decision you need to make.
Can this article alone choose an AI product or model?
No. Treat the article as evidence and context, then validate fit with pricing, privacy requirements, integration effort, benchmark results, workflow tests, and fallback planning.
Continue