gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] manuscripts/Sigs birthday.py birthday.bc


From: Tuomas J. Lukka
Subject: [Gzz-commits] manuscripts/Sigs birthday.py birthday.bc
Date: Mon, 19 May 2003 16:24:03 -0400

CVSROOT:        /cvsroot/gzz
Module name:    manuscripts
Changes by:     Tuomas J. Lukka <address@hidden>        03/05/19 16:24:03

Modified files:
        Sigs           : birthday.py 
Added files:
        Sigs           : birthday.bc 

Log message:
        Ahh, arbitrary-scale floats...

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/manuscripts/Sigs/birthday.bc?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/manuscripts/Sigs/birthday.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: manuscripts/Sigs/birthday.py
diff -u manuscripts/Sigs/birthday.py:1.4 manuscripts/Sigs/birthday.py:1.5
--- manuscripts/Sigs/birthday.py:1.4    Mon May 19 15:58:25 2003
+++ manuscripts/Sigs/birthday.py        Mon May 19 16:24:03 2003
@@ -1,8 +1,12 @@
 from math import *
+import java
 
 def log2birthdayprob(n, k):
     """return log2(p(k balls thrown to n bins, all end up alone))
     """
+    print n, n-k, log(n), log(n-k),  log(n)-log(n-k)
+    n = java.math.BigDecimal(n)
+    k = java.math.BigDecimal(k)
     return (
            (n-k+.5) * (log(n) - log(n-k))
            - k
@@ -14,7 +18,8 @@
 print log2birthdayprob(41, 2)
 print log2birthdayprob(2L**56, 2L**23)
 
-for k in [20, 23]:
-    for n in [56, 60]:
+for n in [1, 2, 3, 4, 56]:
+    for k in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 
19, 20, 21, 22, 23, 24, 25, 26]:
+       if n <= k: continue
        print n,k,log2birthdayprob(2L**n,2L**k)
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]