This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import random | |
import matplotlib.pyplot as plt | |
# Step 1 | |
## show that as the sample size increases the mean of sample is close to population mean | |
# build gamma distribution as population | |
shape, scale = 2., 2. # mean=4, std=2*sqrt(2) | |
mu = shape*scale # mean | |
s = np.random.gamma(shape, scale, 1000000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import random | |
import matplotlib.pyplot as plt | |
# Step 1 | |
## show that as the sample size increases the mean of sample is close to population mean | |
# build gamma distribution as population | |
shape, scale = 2., 2. # mean=4, std=2*sqrt(2) | |
s = np.random.gamma(shape, scale, 1000000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import random | |
import matplotlib.pyplot as plt | |
# build gamma distribution as population | |
shape, scale = 2., 2. # mean=4, std=2*sqrt(2) | |
s = np.random.gamma(shape, scale, 1000000) | |
# Step 1 | |
## sample with different sample size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## standardize part | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import scipy.stats as stats | |
# Step 1 | |
# use last sampling | |
from diffNumSampling import meansample | |
sm = meansample[len(meansample)-1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import random | |
import matplotlib.pyplot as plt | |
# Step 1 | |
# create a population with a gamma distribution | |
shape, scale = 2., 2. # mean=4, std=2*sqrt(2) | |
mu = shape*scale # mean and standard deviation | |
sigma = scale*np.sqrt(shape) | |
s = np.random.gamma(shape, scale, 1000000) |