> ###### > >>> count_duplicates = 0 > >>> for i in range(10): > ... if has_duplication(make_roll(50, 6)): > ... count_duplicates = count_duplicates + 1 > ... > >>> count_duplicates > 1 > >>> 1.0 / 10 > 0.10000000000000001 > ###### > > > Experimentally, we're seeing 1%, but that might just be a fluke. Or maybe > it's just because the trial size is much too small. *grin*
Gaaa. I can't add or subtract. I meant: Experimentally, we're seeing 10%, but that might just be a fluke. Or maybe it's just because the trial size is much too small. > >>> def do_trial(n): > ... """Returns the number of duplicates if we do a n-trial.""" > ... count_duplicates = 0 > ... for i in range(n): > ... if has_duplication(make_roll(50, 6)): > ... count_duplicates = count_duplicates + 1 > ... return float(count_duplicates) / n The comment is wrong. It should be: """Returns the probability of duplicates if we do an n-trial.""" > The variable names 'x' and 'y' suck (I'll try to think of better ones next > time), but I hope that it's clear what we're doing: we're making > do_trial() more general so it can handle different dice rolls. And > because they are parameters in our do_trial() function, we can then see > what the situation loosk like as we get more and more kids in the ^^^^^ Looks, not loosks. Sorry about that! _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor