performance problem in python 2.2
Paul Rubin
phr-n2002b at NOSPAMnightsong.com
Fri Jul 26 20:37:33 EDT 2002
Jeff Davis <jdavis at empires.org> writes:
> > $p = 2**64;
> > $c = $ARGV[0];
> > $n = exp(-($c*$c) / (2*$p));
> > print 1-$n, "\n";
> >
> I learned to never underestimate the usefulness of mathematics in
> programming. Lucky for me, I had a teacher to ask and he gave me a lot of
> good info as well. After giving me some advice (including CS related tips
> that mostly boiled down to "Use assembly, or maybe C if you can about
> getting an answer"), he pointed me to Sterling's Theorem, which seems
> similar to what you did.
Stirling's approximation is pretty complicated to prove. The formula
I gave for hash collisions is a lot simpler and you should be able to
discover it with basic calculus. I'll leave the details as an
exercise for you ;-).
More information about the Python-list
mailing list