i want to create a program which calculates the average of N random numbers taken from a uniform random number distribution.The program must run for Ν=10,100,1000,10000,100000,1000000 random numbers.Then,i have to plot the mean value as a function of N.
I did this:
from scitools.std import *
import matplotlib.pyplot as plt
N=10
distribution=[]
for i in range(1,7):
N*=10
random_numbers=[random.uniform(0,1,size=N)]
distribution.append(random_numbers)
plt.semilogx(array(range(N)),array(distribution).mean())
plt.xlabel('N')
plt.grid(True)
plt.show()
It gives me the error in the title in the line where i do the plot. Also,if there is another ,more pythonic way of doing this i'll appreciate it.
Thank you.