[EMAIL PROTECTED] wrote: > I'm a Python newbie and certainly no expert on statistics, but my wife > was taking a statistics course this summer and to illustrate that > sampling random numbers from a distribution and taking an average of > the samples gives you a random number as the result (bigger sample -> > smaller variance in the calculated random number, converging in on the > mean of the original distribution), I threw together this program: > > #! /usr/bin/python > > import random; > > i=1 > samplen=100 > mean=130 > lo=mean > hi=mean > sd=10 > sum=0 > while(i<=samplen): > x=random.normalvariate(mean,sd) > #print x > if x<lo: lo=x > if x>hi: high=x > sum+=x > i+=1 > print 'sample mean=', sum/samplen, '\n' > print 'low value =', lo > print 'high value=', high
Your code has an error. In the middle of your code, you changed "hi" to "high". -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list