Found that out trying to compute a probability (boy it has been a long time) using Python.
def fac(n):
return reduce(operator.mul,range(2,n+1),1)
Must remember to try to understand how it works, and the Birthday Paradox while I am at it :P This explanation seems simpler / clearer.
As per the Pyhton documentation of the reduce function:
reduce(function, sequence[, initializer])
Roberto De Almeida wrote me an email stating that the operator.mul could be replaced by a lamba function as in:
return reduce(lambda x, y: x * y,range(2,n+1),1)
I get the Python part and believe I understood (or should I say remembered I understood) the Birthday Paradox.
I wanted to compute a generalized version i.e. the probability p(n,d) that at least two integers are the same in a given set of n random integers drawn from a discrete uniform distribution range [1,d]. The approximation did the job nicely!
I can't miss that opportunity to show off my mimeTex.


