Skip to content

Instantly share code, notes, and snippets.

@chaipi-chaya
Last active October 23, 2019 18:30
Show Gist options
  • Save chaipi-chaya/902b01d6a48a612eaafaefddea18ef44 to your computer and use it in GitHub Desktop.
Save chaipi-chaya/902b01d6a48a612eaafaefddea18ef44 to your computer and use it in GitHub Desktop.
Illustration with Python Central Limit Theorem | expected value and standard deviation of sample means
## expect value of sample
import numpy as np
# use last sampling
from diffSampleSize import meansample
# mean and standard deviation from population
shape, scale = 2., 2. # mean=4, std=2*sqrt(2)
sample = meansample[5]
# expected value of sample equal to expect value of population
print("expected value of sample:", np.mean(sample))
print("expected value of population:", shape*scale)
# standard deviation of sample equl to standard deviation of population divided by squre root of n
print("standard deviation of sample:", np.std(sample))
print("standard deviation of population:", scale*np.sqrt(shape))
print("standard deviation of population divided by squre root of sample size:", scale*np.sqrt(shape)/np.sqrt(1000))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment