Two Plus Two Newer Archives  

Go Back   Two Plus Two Newer Archives > General Gambling > Probability
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 10-18-2007, 10:00 PM
R Gibert R Gibert is offline
Member
 
Join Date: Jan 2006
Posts: 53
Default Re: Prob of not drawing card in x trials...help

46.311% confirms your other calc with the following more general program:
<font class="small">Code:</font><hr /><pre>
from random import *

n = 100000
t = 90
k = 52
c = 0
deck = range(52)
for j in range(n):
m = [False]*52
for i in range(t):
d = sample(deck,2)
m[d[0]] = True
m[d[1]] = True
if len(filter(lambda x: x == False, m)) &lt; 2:
c += 1
print 1 - float(c)/n
</pre><hr />
I traded efficiency for something more readable. Retaining the old approach was workable, but the bit twiddling would have produced an ugly result.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:36 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.