Created
February 16, 2015 15:05
-
-
Save cigrainger/1153c053d0a3aaa15d3d to your computer and use it in GitHub Desktop.
meanvar
This file contains hidden or 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 | |
from numpy import random | |
m = 1000 | |
tot_n = np.zeros(m) | |
for i in list(range(m)): | |
n = 1 | |
mcint = random.randn(n) | |
mean = str(np.mean(mcint)).split('.') | |
while mean[1][:3] != '000': | |
mcint = random.randn(n) | |
mean = str(np.mean(mcint)).split('.') | |
n += 1 | |
tot_n[i] = n | |
avg_n = np.mean(tot_n) | |
print(avg_n) | |
tot_n = np.zeros(m) | |
for i in list(range(m)): | |
n = 1 | |
mcint = random.randn(n) | |
var = str(np.var(mcint)).split('.') | |
while var[1][:3] != '000': | |
mcint = random.randn(n) | |
var = str(np.var(mcint)).split('.') | |
n += 1 | |
tot_n[i] = n | |
avg_n = np.mean(tot_n) | |
print(avg_n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment