On Tuesday, June 16, 2015 at 6:01:06 PM UTC-4, Thomas 'PointedEars' Lahn wrote: > Ned Batchelder wrote: > > > [...] > > This is done empirically, by producing `nseq` sequences of > > `nrolls` rolls of the die. Each sequence is examined to > > see if it has a zero. The total number of no-zero > > sequences divided `nseq` is the probability. > > No, it is not. It is the relative frequency for *this* number of trials and > *this* run of the experiment. > > > """ > > no_zeros = 0 > > for _ in xrange(nseq): > > seq = die_rolls(nrolls) > > if not any_zeros(seq): > > no_zeros += 1 > > return float(no_zeros)/nseq > > > > for n in range(10, 101, 10): > > # Calculate the probability of getting no zeros by trying > > # it a million times. > > prob = probability_of_no_zero(n, 1000000) > > print "n = {:3d}, P(no zero) = {:.8f}".format(n, prob) > > > > > > > > Running this gives: > > > > $ pypy testrandom.py > > n = 10, P(no zero) = 0.34867300 > > n = 20, P(no zero) = 0.12121900 > > n = 30, P(no zero) = 0.04267000 > > n = 40, P(no zero) = 0.01476600 > > n = 50, P(no zero) = 0.00519900 > > n = 60, P(no zero) = 0.00174100 > > n = 70, P(no zero) = 0.00061600 > > n = 80, P(no zero) = 0.00020600 > > n = 90, P(no zero) = 0.00006300 > > n = 100, P(no zero) = 0.00002400 > > > > > > As n increases, the probability of having no zeros goes down. > > Your programmatic "proof", as all the other intuitive-empirical "proofs", > and all the other counter-arguments posted before in this thread, is flawed. > As others have pointed out at the beginning of this thread, you *cannot* > measure or calculate probability or determine randomness programmatically > (at least not with this program).
You *can* estimate probability with a program, which is what is happening here. > I repeat: Probability is what relative > frequency (which you can measure) *approaches* for *large* numbers. 100 is > anything but large, to begin with. The number of trials in this program is not 100, it is 1 million. You seem uninterested in trying to understand. > What is "large" depends on the > experiment, not on the experimentator. And with independent events, the > probability for getting zero does not increase because you have been getting > non-zeros before. It simply does not work this way. Again, if you look at the code, you'll see that we are not talking about the probability of getting a zero on the next roll. We are talking about the probability of getting no zeros in an N-roll sequence. I have no idea how you have misunderstood this for so long. I'll stop trying to explain it. --Ned. -- https://mail.python.org/mailman/listinfo/python-list