[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] manuscripts/Sigs birthday.py
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] manuscripts/Sigs birthday.py |
Date: |
Mon, 19 May 2003 15:58:25 -0400 |
CVSROOT: /cvsroot/gzz
Module name: manuscripts
Changes by: Tuomas J. Lukka <address@hidden> 03/05/19 15:58:25
Modified files:
Sigs : birthday.py
Log message:
drive out numerical inaccuracy
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/manuscripts/Sigs/birthday.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
Patches:
Index: manuscripts/Sigs/birthday.py
diff -u manuscripts/Sigs/birthday.py:1.3 manuscripts/Sigs/birthday.py:1.4
--- manuscripts/Sigs/birthday.py:1.3 Mon May 19 15:52:24 2003
+++ manuscripts/Sigs/birthday.py Mon May 19 15:58:25 2003
@@ -4,10 +4,8 @@
"""return log2(p(k balls thrown to n bins, all end up alone))
"""
return (
- (n+.5) * log(n)
- - (n-k+.5) * log(n-k)
+ (n-k+.5) * (log(n) - log(n-k))
- k
- - k * log(n)
) / log(2)
print log2birthdayprob(41, 31)
@@ -15,3 +13,8 @@
print log2birthdayprob(41, 11)
print log2birthdayprob(41, 2)
print log2birthdayprob(2L**56, 2L**23)
+
+for k in [20, 23]:
+ for n in [56, 60]:
+ print n,k,log2birthdayprob(2L**n,2L**k)
+