Re: Problem with extremely small real number

2007-09-03 Thread Roberto Bonvallet
On 3 sep, 10:56, Andrea <[EMAIL PROTECTED]> wrote: > def binomial(n, k): > assert n>0 and isinstance(n, (int, long)) and isinstance(k, > (int,long)) Don't use assert to check whether the parameters have the right value. assert should be used to claim that a certain condition always hold i

Re: Problem with extremely small real number

2007-09-03 Thread Arnaud Delobelle
On Sep 3, 3:56 pm, Andrea <[EMAIL PROTECTED]> wrote: > Hi, > I need to calculate this probability P!/{n \choose p}, varying both n > and p, n takes values in this range [512:1024] and p in [2:12]. > So i write this code in python: > > def factorial(n): > result=1 > if n==0: return 1

Re: Problem with extremely small real number

2007-09-03 Thread Fabio Z Tessitore
Il Mon, 03 Sep 2007 07:56:10 -0700, Andrea ha scritto: > [cut] > > I want to call factorial(2)//binomial(1024,2) for example, in this way > trivially I obtain 0 as probability, how can I obtain the probability > forcing this division to output extremely small real numbers int to float will h

Re: Problem with extremely small real number

2007-09-03 Thread Duncan Smith
Andrea wrote: > Hi, > I need to calculate this probability P!/{n \choose p}, varying both n > and p, n takes values in this range [512:1024] and p in [2:12]. > So i write this code in python: > > def factorial(n): > result=1 > if n==0: return 1 > for i in xrange(1, abs(n)+1): >

Problem with extremely small real number

2007-09-03 Thread Andrea
Hi, I need to calculate this probability P!/{n \choose p}, varying both n and p, n takes values in this range [512:1024] and p in [2:12]. So i write this code in python: def factorial(n): result=1 if n==0: return 1 for i in xrange(1, abs(n)+1): result = i*re