2
   

Can you answer this mathematical poseur<?

 
 
aidan
 
  1  
Reply Wed 21 Jan, 2009 09:47 am
@aidan,
I meant to say Drewdad is right
0 Replies
 
solipsister
 
  1  
Reply Wed 21 Jan, 2009 05:00 pm
Getting warmer
0 Replies
 
rg123
 
  1  
Reply Wed 21 Jan, 2009 07:12 pm
@solipsister,
Three of the 47 possibilities at card 3 which do not snap to card 2 would have snapped to card 1. For each of those 3 possibilities, there are only 2 possible snaps left at card 4. The other 44 possibilities at card 3 each have the standard 3 possible snaps at card 4. So, the chance to snap at card 4 which takes this into account is, I believe:

(48/51)x(3/50)x(2/49)+(48/51)x(44/50)x(3/49)
epenthesis
 
  1  
Reply Wed 21 Jan, 2009 08:11 pm
@rg123,
Bella Dea's answer looks correct
0 Replies
 
DrewDad
 
  1  
Reply Wed 21 Jan, 2009 09:33 pm
Snaps are more common than I thought

52 random cards
DrewDad
 
  1  
Reply Wed 21 Jan, 2009 09:34 pm
@DrewDad,
I hope to provide the information experimentally...

I've created a program to test how many cards before a snap. I'll post the results of 1000 iterations.....
0 Replies
 
DrewDad
 
  1  
Reply Wed 21 Jan, 2009 10:28 pm
My code:

Function RndInt( )
' Retrieves TRUE random integers from http://www.random.org/
'
' Arguments:
' myMin [int] lowest possible value for the random integer
' myMax [int] highest possible value for the random integer
' myLength [int] the number of random integers that should be retrieved
'
' Returns:
' [array of int] array with the requested number of random integers within
' the specified range OR an [array of string] error message
'
' Note:
' Read http://www.random.org/quota/ if you intend to use this script often
'
' Written by Rob van der Woude
' http://www.robvanderwoude.com
Dim intResult, i, intStatus, objHTTP, strAgent, strResult, strURL

strURL = "http://www.random.org/integers/?num=1&min=1&max=13&col=1&base=10&format=plain&rnd=new"
strAgent = "Mozilla/4.0 (compatible; MyApp 1.0; Windows NT 5.1)"

Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )
objHTTP.Open "GET", strURL, False
objHTTP.SetRequestHeader "User-Agent", strAgent

On Error Resume Next
objHTTP.Send
intStatus = objHTTP.Status
strResult = Trim( Replace( objHTTP.ResponseText, vbLf, " " ) )
intResult = int( strResult )
On Error Goto 0

If intStatus = 200 Then
RndInt = intResult
Else
RndInt = -1
End If

Set objHTTP = Nothing
End Function

Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.CreateTextFile("c:\cnx\coding\cardtrick.txt", True)

for i = 1 to 1000
ones = 0
twos = 0
threes = 0
fours = 0
fives = 0
sixes = 0
sevens = 0
eights = 0
nines = 0
tens = 0
jacks = 0
queens = 0
kings = 0

thiscard = 0
lastcard = 0
cardcount = 0
snap = 0


do

do


thiscard = RndInt()
'wscript.echo thiscard

select case thiscard
case 1
if ones = 4 then
thiscard = -1
else
ones = ones +1
end if
case 2
if twos = 4 then
thiscard = -1
else
twos = ones +1
end if
case 3
if threes = 4 then
thiscard = -1
else
threes = ones +1
end if
case 4
if fours = 4 then
thiscard = -1
else
fours = ones +1
end if
case 5
if fives = 4 then
thiscard = -1
else
fives = ones +1
end if
case 6
if sixes = 4 then
thiscard = -1
else
sixes = ones +1
end if
case 7
if sevens = 4 then
thiscard = -1
else
sevens = ones +1
end if
case 8
if eights = 4 then
thiscard = -1
else
eights = ones +1
end if
case 9
if nines = 4 then
thiscard = -1
else
nines = ones +1
end if
case 10
if tens = 4 then
thiscard = -1
else
tens = ones +1
end if
case 11
if jacks = 4 then
thiscard = -1
else
jacks = ones +1
end if
case 12
if queens = 4 then
thiscard = -1
else
queens = ones +1
end if
case 13
if kings = 4 then
thiscard = -1
else
kings = ones +1
end if
end select
loop until thiscard <> -1

cardcount = cardcount +1

' wscript.echo "This card = " & thiscard & " last card = " & lastcard

if thiscard = lastcard then
snap = 1
end if

lastcard = thiscard

loop until (snap = 1) or (cardcount = 52)


if snap = 1 then
filetxt.WriteLine(cardcount)
else
filetxt.WriteLine("53")
end if

next
filetxt.Close

0 Replies
 
DrewDad
 
  1  
Reply Wed 21 Jan, 2009 10:40 pm
Nevermind....

I made an atrocious mistake in how I select cards.
solipsister
 
  1  
Reply Wed 21 Jan, 2009 10:44 pm
@DrewDad,
and simulation is not an answer
rg123
 
  1  
Reply Wed 21 Jan, 2009 11:21 pm
@solipsister,
I'll venture one more:

Based on my last post, the chance to NOT snap at card 4 is:
(48/51)x(3/50)x(47/49)+(48/51)x(44/50)x(46/49)

Now, to expand this for card 5:

Card 4 might be a value match for card 1 or card 2 or neither (but not both, since that would have meant a previous snap).

In the first operand above (where card three is a value match for card 1):
- Card 4 cannot match card 1 (would have meant a snap at card 4, and we are past that to card 5 here.)
- Card 4 matches card 2 in 3/49 possibilities, and for those, card 5 snaps in 2/48
- Card 4 matches neither card 1 or card 2 in 44/49 possibilities, and for those, card 5 snaps in 3/48

In the second operand above (where card three is not a value match for card 1):
- Card 4 matches card 1 in 3/49 possibilities, and for those, card 5 snaps in 2/48
- Card 4 matches card 2 in 3/49 possibilities, and for those, card 5 snaps in 2/48
- Card 4 matches neither card 1 nor card 2 in 40/49 possibilities, and for those, card 5 snaps in 3/48

Putting this all together, if I haven't made any mistakes, the chance to snap at card 5 is:
(48/51)x(3/50)x(3/49)x(2/48)+(48/51)x(3/50)x(44/49)x(3/48)
+(48/51)x(44/50)x(6/49)x(2/48)+(48/51)x(44/50)x(40/49)x(3/48)

Looks like you have to keep expanding out the operands like this for every subsequent card - tedious, but this is the pattern of what you have to do, I think.
solipsister
 
  1  
Reply Wed 21 Jan, 2009 11:24 pm
@rg123,
back to school for you rg123
0 Replies
 
markr
 
  1  
Reply Sat 24 Jan, 2009 12:12 am
It's a matter of probability, not statistics. The answer might be expected to be:
SUM[n=2 to 52, n * P(snap on the nth card, but not before]
which is the formula for expected value.

However, there is a fly in the ointment. There is a greater than zero probability of no snap after all the cards are played. What weight (n in the above formula) is multiplied by this probability?

I found these comments at a site dealing with this question:
Quote:
52x51x50 etc in maths 52! (the probability of any one number or card appearing)
The chance of it being a snap on the number is 3 chances in 51 (the total being chosen from is a finite number) The chances of it being a snap on suit are Nil THE SAME SUIT. 1 in 3 any suit (except the the one play) Which leaves 1 in just under 3 of it being a snap (I won't bore you with the stat's)!

Quote:
The chance of snap with the 2nd card is 3/51(.0588). 3rd card (48/51)*(3/50) (.0565) ie no snap 2nd card then snap 3rd card. 4th card (48/51)*(47/50)*(3/49) (0.542) less the chance that the 4th card number was also played as card #1 and so on ad latin. The cumulative probability reaches 0.5 (the average) on the 12th card. Scintillating question!

Quote:
Yay! One less than common sense would suggest.
There is a roughly one in thirteen chance that a card drawn equals the one before so the expected number of cards before "Snap" might be expected to be 13.
It is only "roughly one in thirteen" because in one deck the same cards cannot come up twice making the most likely number of cards 12.


The first response is, at best, incomplete.
The second response seems to imply that the answer occurs when the cumulative probability reaches .5, which is nonsense (look at the formula for expected value).
The third response seems to assume that the answer is an integer and gives an "intuitive" argument for it being 12 based on the fact that it should be close to 13.
None of the responses addresses the fact that a snap may not occur.
solipsister
 
  1  
Reply Sat 24 Jan, 2009 12:57 am
@markr,
hello markr

agreed those attempts are incorrect

however, the expected value is the sum of the probability of the first pair from card two to card 52 times that cards position so if there is no snap by card 52 the endless potential cards beyond 52 are not part of the function

continuing the series beyond card 4 (ignoring the minuscule probabilities of cards having been turned over in non snap positions?) gives an expectation ie sum of the probability times card number dealt of :

drum roll

you guessed it

i dare not say

markr
 
  1  
Reply Sat 24 Jan, 2009 01:18 am
@solipsister,
So you're limiting the deck to configurations that contain a snap.
I'd like to see an answer that doesn't ignore "miniscule" probabilities.
markr
 
  1  
Reply Sat 24 Jan, 2009 02:27 am
@DrewDad,
My 10,000,000 trial simulation yielded 15.437 after throwing out 453971 trials with no snaps.
0 Replies
 
solipsister
 
  1  
Reply Sat 24 Jan, 2009 02:32 am
@markr,
the deck is limited to 51 possible chances of snap on the next card so the probability density function is finite

so would i, but it's too unwieldy for me, and the minuscule probabilities are SUBTRACTED from the chances for snap with later cards given one or more of that value may have been played earlier so an answer which ignores those values does not over estimate the expected value

i get 12.065 (leaving out the SUBTRACTION) above based on the sum of expectations to card 52 extrapolating from the probabilities identified earlier
solipsister
 
  1  
Reply Sat 24 Jan, 2009 02:45 am
@solipsister,
probability snap card # expectation

0.058823529 1 0.058823529
0.056470588 2 0.112941176
0.054165666 3 0.162496999
0.051810637 4 0.207242549
0.049507942 5 0.247539712
0.047257581 6 0.283545488
0.045059554 7 0.31541688
0.042913861 8 0.34331089
0.040820502 9 0.367384519
0.038779477 10 0.38779477
0.036790786 11 0.404698645
0.034854429 12 0.418253145
0.032970406 13 0.428615272
0.031138716 14 0.435942029
0.029359361 15 0.440390417
0.02763234 16 0.442117438
0.025957653 17 0.441280095
0.024335299 18 0.438035388
0.02276528 19 0.43254032
0.021247595 20 0.424951894
0.019782243 21 0.41542711
0.018369226 22 0.404122971
0.017008543 23 0.391196479
0.015700193 24 0.376804635
0.014444178 25 0.361104442
0.013240496 26 0.344252901
0.012089149 27 0.326407015
0.010990135 28 0.307723785
0.009943456 29 0.288360214
0.00894911 30 0.268473302
0.008007098 31 0.248220053
0.007117421 32 0.227757468
0.006280077 33 0.207242549
0.005495068 34 0.186832298
0.004762392 35 0.166683717
0.00408205 36 0.146953808
0.003454042 37 0.127799572
0.002878369 38 0.109378012
0.002355029 39 0.09184613
0.001884023 40 0.075360927
0.001465351 41 0.060079406
0.001099014 42 0.046158568
0.00078501 43 0.033755415
0.00052334 44 0.02302695
0.000314004 45 0.014130174
0.000157002 46 0.007222089
0.0000523340 47 0.002459697
5.2334E-05 48 0.002512031
5.2334E-05 49 0.002564365
5.2334E-05 50 0.002616699
5.2334E-05 51 0.002669033


0.964098892 12.06246297


3.6% no snap 12.06 expectation

markr
 
  1  
Reply Sat 24 Jan, 2009 02:48 am
@solipsister,
My second run of 10,000,000 trials yielded 15.433 after throwing out 455230 trials with no snaps. I wonder why we're almost 3.4 apart. Perhaps those miniscule probabilities aren't so miniscule?

Can you post your formula? It's not clear to me what you're excluding. If it's too unwieldy to post the whole thing, how about up to 6 or so cards?

Thanks,
Mark
markr
 
  1  
Reply Sat 24 Jan, 2009 03:02 am
@solipsister,
My last post was being entered while you posted your list. I can account for some of the difference between your answer and my sim results. I would argue that you should be multiplying your probabilities by 2 through 52 instead of 1 through 51. You have to turn over at least 2 cards to get a snap. That gets your number up to 13.0265619.

I'm still interested in seeing your formulas so I can determine what is being excluded.
0 Replies
 
solipsister
 
  1  
Reply Sat 24 Jan, 2009 03:43 am
@markr,
in my next guestimate i will exclude SOME of my previous excel typing errors

on the nth card played for all n from 2 to 52 the expectation is n times

3/51
48/51 x 3/50
48/51 x 47/50 x 3/49
48/51 x 47/50 x 46/49 x 3/48
48/51 x 47/50 x 46/49 x 45/48 x 3/47

to be continued

 

Related Topics

Amount of Time - Question by Randy Dandy
Statistics - Question by ekkline
Math of infinity - Discussion by dalehileman
Probability Question. - Discussion by babemomlover
Do I make the mistake? - Question by tetupioxi
 
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 04/30/2024 at 02:10:50