Created
December 27, 2016 12:57
-
-
Save wasdee/15d6d55cff754d3daeced33b0629cb14 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/python | |
p = 0.5 | |
sample_size = [10 ** x for x in range(1,6)] | |
replicates = 10000 | |
biases = [] | |
for n in sample_size: | |
bias = np.empty(replicates) | |
for i in range(replicates): | |
true_sample = np.random.normal(size=n) | |
negative_values = true_sample<0 | |
missing = np.random.binomial(1, p ,n).astype(bool) | |
obseved_sample = true_sample[-(negative_values & missing)] | |
bias[i] = obseved_sample.mean() | |
biases.append(bias) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment