相加随机变量

Python 概率基础

Alexander A. Ramírez M.

CEO @ Synergy Vision

中心极限定理(CLT)

随机变量之和在变量个数趋于无穷大时趋近正态分布。

条件:

  • 变量须同分布。
  • 变量须相互独立。
Python 概率基础

泊松分布的样本生成动图

Python 概率基础

从总体中随机抽取的示意图

Python 概率基础

从总体中再次随机抽取的示意图

Python 概率基础

样本均值计算与直方图

Python 概率基础

泊松总体图

# Add the imports
from scipy.stats import poisson, describe
from matplotlib import pyplot as plt
import numpy as np
# Generate the population
population = poisson.rvs(mu=2, size=1000, random_state=20)
# Draw the histogram with labels
plt.hist(population, bins=range(9), width=0.8)
plt.show()
Python 概率基础

泊松总体直方图

Python 概率基础

样本均值图

# Generate 350 sample means, selecting
# from population values
np.random.seed(42)

# Define list of sample means
sample_means = []
for _ in range(350):
    # Select 10 from population
    sample = np.random.choice(population, 10)
    # Calculate sample mean of sample
    sample_means.append(describe(sample).mean)
Python 概率基础

样本均值图(续)

$$ $$

# Draw histogram with labels
plt.xlabel("Sample mean values")
plt.ylabel("Frequency")
plt.title("Sample means histogram")
plt.hist(sample_means)
plt.show()

钟形的样本均值直方图

Python 概率基础

来相加随机变量

Python 概率基础

Preparing Video For Download...