View Full Version : Martingale Paradox Claim
CoreyWhite
14th September 2006, 11:10 AM
So it has been a year since I proposed my own million dollar challenge, and was banned because I offered to buy up to $5,000 lottery tickets for potential psychics.
And since that time I have been growing as a psychic, but although I haven't struck it rich at the lottery, I have been learning and working as a free tarot card reader and psychic entertainer. In my spare time I've even been solving a few crimes. And doing volunteer work at churches and nursing homes.
And now I've finally come up with a new claim that is scientifically verifiable, because I realize that ordinary psychic abilities aren't enough to impress James Randi (or even winning the lottery).
I've uploaded this experiment to Wikipedia now, and we have already covered it on this forum in the Fun in the Casino thread. I noticed that everyone on the forum was skeptical of my betting strategy, but I've created computer models to prove it is empirically verifiable. So if James Randi wants to challenge this betting strategy I'm willing to play this game with him.
He can bring one million dollars in pennies, and I can bring $5,000 in pennies. We play according to the rules of this game and winner takes all! 8)
Well, I doubt he will want to play, but getting a post like this on Wikipedia is like winning the million dollar challenge to me, and just as good. Because almost no one in the world has understood the math behind this idea, and people who believe in this theory are under sharp criticism. So it may be one small step for me, but it is one giant leap for the education of mankind.
The Martingale Paradox
It is possible to use martingale probability theory to beat some games of chance. In a fair game of coin toss, where the odds reach an equilibrium of 50/50 chain reactions do occur. This can be explained using martingale probability theory, but in simpler terms it only shows an example of how order emerges out of chaos.
Example: One player has 3 pennies, and another player has only 1 penny. A fair coin is tossed every round to determine if a penny is won or lost for either player. The odds are 3/4 that player A (Who begins with 3 pennies) will win the game. This is entirely different than the martingale betting strategy, because only 1 penny is bet for each round of the game.
Because there are 3 ways player A may win, and only one way player B can win, player A has a concrete advantage. Player B, only wins in the event that the coin is tossed in his favor 3 times in a row, while player A can win on the first throw. Or he can win after losing the first coin toss, or he can win after losing the second coin toss. So the odds are 75% that he (or she) will win in this game.
Upon further analysis it is possible to calculate the average number of coin flips before player A is likely to win. The equation k(n-k) works for perfectly fair games according to martingale probability theory to solve this problem. In this case 3(4-3) solves the problem, so on average it takes 3 coin flips for player A to win.
To show that chain reactions occur you only have to move from the probability of winning the first game, and multiply it by the probabilities of winning the following games. For example, if 3 pennies are used to play this game in an attempt to win one penny, the odds are 3/4. And once that penny is collected there is now a 4/5th chance of winning another penny.
So statistics tells us that there is a (3/4) * (4/5) * (5/6) * (7/8) * (8/9) * (9/10) = 30% chance of the 3 pennies growing into a pile of 10.
But in repeatable tests you will find that on average there is not a net win or loss in this game. If there is a 75% chance of winning 1 penny, and a 25% chance of losing 3. The two odds cancel each other out, to create an equilibrium in 50/50 games.
And at the same time we can see that despite the fact that the initial value of coins reaches an equilibrium when the pattern is extended to any length, we can show a concrete advantage to begining with 3 pennies, instead of begining with one.
In the last example player A had a 30% chance of winning 7 pennies, and totalling 10 in all. If we started with only one penny then player A would just have to total 8 pennies in order to earn 7. So lets look at the math:
(1/2) * (2/3) * (3/4) * (4/5) * (5/6) * (6/7) * (7/8) = 12.5%
So we can cleary see that even though winning 7 pennies has the same expected value as losing 1 penny. Outside of repeatable tests the odds of earning 7 pennies is clearly higher if you begin with 3.
This experiment is empirically verifiable, and was first published on usenet by a member of the sci.physics and sci.math groups. The theory was titled "Corey's Punctuated Theory Of Chain Reactions Within An Equilibrium Of Chaos". Because it is mathematics it shouldn't be considered independent research, and can be proven by referencing the books in the martingale probability theory wikipedia page.
Retrieved from Wikipedia
Cuddles
14th September 2006, 11:16 AM
This has already been shown to be wrong in the thread you mentioned. I should also point out that anyone can post anything they like on wikipedia so I'm not sure why you would think of that as some lind of achievment. When you get it in the Britannica I'll be impressed.
Soapy Sam
14th September 2006, 11:28 AM
I do not understand your purpose here.
If you do have a mathematically verifiable gambling strategy it is, by definition, not paranormal and of no interest at all to JREF.
If you do not, then it is of no interest to JREF.
So good luck at the casino.
Overman
14th September 2006, 11:39 AM
Heads I win, Tails you lose.
petre
14th September 2006, 11:53 AM
I got as far as the first sentence. The reason for his banning was easily determined in under 60 seconds of searching. Further, I found none of the information described on the Wikipedia site.
It seems clear this poster believes he can alter reality by simply stating what he believes to be true. I find this is not the case.
IXP
14th September 2006, 01:28 PM
Mr White,
Do you really not understand why your betting strategy cannot win any money in the long run?
What you state about 2 people, one starting with 1 coin and one starting with 3 coins are not equally likely to get to 4 coins. This is trivially obvious. However, this does not change the odds of winning or losing money over many trials.
Please try simulating the following:
For each trial start with 3 pennies. Play a 50/50 game until either one of the following occurs: you have 4 pennies, or you have lost all 3. In the first case, count a win of 1, in the second case a loss of 3.
Add up the wins and losses over a large number of trials. You will find that your average win will do a random walk around 0 instead of continually growing like you seem to think.
IXP
TobiasTheViking
14th September 2006, 03:17 PM
So it has been a year since I proposed my own million dollar challenge, and was banned because I offered to buy up to $5,000 lottery tickets for potential psychics.
Ok, the rest of your message is irrelevant now that you have been shown to being a liar.
For those who don't have the information here it is.
Corey started his career here by posting this message.
I Corey White am offering to buy up to $5,000 in Ohio Lottery Tickets. Any psychic on the JREF Forum who wishes to accept CoreyWhite's Million Dollar Challenge can play up to 100 lottery numbers, from any of the Ohio Lottery Games. If your numbers are played after I have informed you that I bought the ticket, I will write you a check for the prize money!!!
SWEET DOOD!
It was, however, quickly uncovered that Corey couldn't be trusted, based, amongst others, on the following message
Acording to my source, James Randi has stolen the million dollar
prize. I don't think James Randi qualifies to take his own challenge, but
after he takes the prize money to Vegas he may prove he has psychic powers
after all.
In other news, I am starting a new $1,000,000 prize.
It will be a website
where psychics everywhere can register to play, and I will put up $5,000 to
buy lottery tickets with. The top lotto numbers the psychics picks will be
played, and we will see if we can win $1,000,000 for the site.
Happy Thanks-Giving
http://groups.google.com/group/sci.skeptic/browse_thread/thread/2b865a341c5d4ad5/a9ca01986270f03a?lnk=raot#a9ca01986270f03a
This resulted in him being banned.
Shortly thereafter he was allowed to use his account for 7 days so he could either appologize, or come up with evidence.. that resulted in the following post.
>I have discussed the changes you have made against Mr. Randi with the
>JREF staff, and we have decided to allow you to use your forum account
>for 7 days effective immediately. During that time, we ask that you
>provide any evidence you might have for the claims you have made
>regarding Mr. Randi's illegal activity.
>
>
>
>If you fail to do so, your account will be permanently banned and the
>James Randi Educational Foundation will pursue legal action against
>you.
>
>
>
>Jeff Wagg
>
>JREF Webmaster
I am formally appologizing to James Randi, and hope he accepts the fact that words are not against the law even if I don't have proof of this claim. There is no law against a joke, even if there is hurt feelings.
I will remove myself from this forum, but would rather not meet with your lawyer in a court of law, evidence aside. Thanks for this time to appologize, it is a nice offer.
As apologies goes, that one is not only bad, it is gut wrenchingly awfull.
Any further corespondence with this ... individual ... seems irrelevant with these facts at hand. Especially because he have been told this earlier today, and still continue with the same lies.
His account was NOT closed after the 7 day period. But he thought it was, which resulted in him coming to the channel on skepticsrock and complaining about him not being alowed to post on the forum. Because Randi(and the forum at large) was afraid of him. In the channel it was found out who he was, and what he had done. He was told his account was not closed, and he left.
He slandered back then, he slandered in the channel earlier today, and he slandered in the opening message here.
He is a compulsive liar and it is no good to spend any time on him.
Bradk3
14th September 2006, 03:38 PM
http://www.fadeeva.com/Beasts/kitten-fluff2.jpg
Meow.
T'ai Chi
15th September 2006, 06:53 PM
My quick impressions:
Expected winnings for each player:
expected value for player 1=
P(win)*$win - P(lose)*$lose =
3/4*1 penny - 1/4*3 pennies = 0.
expected value for player 2=
P(win)*$win - P(lose)*$lose =
1/4*3 pennies - 3/4*1 penny = 0.
T'ai Chi
16th September 2006, 04:05 AM
Here's a quick TI calculator program I wrote for it:
penny()
#initialize winning counts
0->winp1
0->winp2
#initialize banks
0->bankp1
0->bankp2
#initialize first time played
1->t
Lbl start
#initialize number of pennies each player has at the start
3->player1
1->player2
Lbl a
ClrIO
Disp player1, player2
Disp approx(winp1/t), approx(winp2/t)
Disp bankp1, bankp2
Disp t
#if someone wins
If player1=0: Goto b
If player2=0: Goto b
#the flip, 1 is heads
rand(2)-1->p1
rand(2)-1->p2
If p1=1: player2-1->player2
If p1=1: player1+1->player1
If p2=1: player1-1->player1
If p2=1: player2+1->player2
Goto a
Lbl b
If player2=0: winp1+1->winp1
If player2=0: bankp1+1->bankp1
If player2=0: bankp2-1->bankp2
If player1=0: winp2+1->winp2
If player1=0: bankp2+3->bankp2
If player1=0: bankp1-3->bankp1
t+1->t
Goto start
EndPrgm
CoreyWhite
16th September 2006, 07:34 AM
What are your conclusions after running your program? I wrote a program in C and concluded that even though the expected value of the two games were the same, one probability was higher. So you had an advantage playing the first game. Expected value isn't the only kind of value.
Jekyll
16th September 2006, 07:36 AM
I do not understand your purpose here.
If you do have a mathematically verifiable gambling strategy it is, by definition, not paranormal and of no interest at all to JREF.
If you do not, then it is of no interest to JREF.
So good luck at the casino.
Mind you if he can win with that stratergy it would be :D :D ing paranormal.
CoreyWhite
16th September 2006, 08:24 AM
I can also explain the laws of nature with these prinicples. If we look at the equation for gravity on earth, which accelerates at 9.8 m/s we can derive an acceptable answer from the earlier equations. The gravity equation I am using is sqrt(2*n/9.8).
In this example we are dropping a ball from 4.9 meters, and you can see it takes one second to land.
t = sqrt( ( 2(4.9 m) ) / ( 9.8 m/s^2 ) ) = 1 s
So here is my gravity theory. We are using the quadratic formula to
solve: 2*n/9.8 = k(n-k) , for k. (The formula k(n-k) finds the average number of coin flips).
k=(1/14) (7n +- sqrt(49 n^2 - 40 n)).
So now an example...
We are dropping a ball from 10 meters above the ground. So we plug 10
meters into n to solve for k.
k=(1/14) (7n +- sqrt(49 n^2 - 40 n))
k=9.791574237
My question to calculate the average number of coin flips in my game is
k(n-k), so we plug in k & n:
k*(10-k) = 2.040816327 = average number of coin flips
Now we take the square root of the average number of flips to get the
actual time it takes to land:
sqrt(avg flips) = 1.428571429 = number of seconds to land.
Now finally to factor in a problem with my equation we say that if k is
9.791574327, that means our large gravity pile is that many pennies.
And our small gravity pile is exactly 0.208425673 pennies!
William Smith
16th September 2006, 08:34 AM
How does this relate to the JREF Challenge, Mr. White?
T'ai Chi
16th September 2006, 09:37 AM
What are your conclusions after running your program? I wrote a program in C and concluded that even though the expected value of the two games were the same, one probability was higher.
I believe one can conclude that without even running the program.
So you had an advantage playing the first game. Expected value isn't the only kind of value.
I believe if you play the game once, then stop forever, you'll have an advantage being player 1. But mostly games are talked about in terms of repeatedly playing them, and keeping track of results.
T'ai Chi
16th September 2006, 09:39 AM
How does this relate to the JREF Challenge, Mr. White?
It is in the JREF challenge forum- that's how it relates. Duh!
;)
T'ai Chi
16th September 2006, 10:21 AM
Corey, are you saying
player 1's earnings are greater than player 2's earnings
for a large number of trials of the game?
My program confirms what IXP said
Add up the wins and losses over a large number of trials. You will find that your average win will do a random walk around 0 instead of continually growing like you seem to think.
and I will post the full program and a pic of player 1's earnings for 1000 trials. It fluctuates above and below the earnings = 0 line.
CoreyWhite
16th September 2006, 10:55 AM
The theory should hold for a small number of trials, and maybe a finite number of trials. Why not run a test and see?
nathan
16th September 2006, 11:08 AM
I can also explain the laws of nature with these prinicples. If we look at the equation for gravity on earth, which accelerates at 9.8 m/s we can derive an acceptable answer from the earlier equations. The gravity equation I am using is sqrt(2*n/9.8). ...
WARNING: Internet may contain nuts
geni
16th September 2006, 01:25 PM
This has already been shown to be wrong in the thread you mentioned. I should also point out that anyone can post anything they like on wikipedia
Not so as this individual found out (still not sure if I regret telling him to try publishing in Social Text).
IXP
16th September 2006, 02:33 PM
What are your conclusions after running your program? I wrote a program in C and concluded that even though the expected value of the two games were the same, one probability was higher. So you had an advantage playing the first game. Expected value isn't the only kind of value.
Corey,
First player starts 3 coins and tries to win 1
Second player starts with 1 coin and tries to win 1
Yes, the first player has higher probablity of succeeding, but when he fails, he loses 3. The second player has a lower probability of succeeding, but when he fails, he lose only 1. That is the part you are ignoring.
IXP
Calcas
16th September 2006, 09:00 PM
WARNING: Internet may contain nuts
Best line of the day...LOL
William Smith
16th September 2006, 09:57 PM
CoreyWhite, do you intend to apply for the JREF Challenge with what you claim in this thread?
If not, how does it relate to the JREF Challenge, i.e. why did you post here?
T'ai Chi
16th September 2006, 10:51 PM
I see what I believe Corey is seeing, but I'm not sure if I'm just not running enough trials, or if my program is doing exactly what I want it to do for that matter.
I ran 2397 trials (that's just when I stopped my program), and graphed player 1's winnings (see attached pic), and while it dipped below the winnings = 0 line a few times, it never crosses it again after 673 trials.
Now maybe for some larger number of trials it comes back and maybe dips down to average out?
Here's the program:
penny()
#initialize player 1 earning vector
{0}->ep1
#and trial vector
{1}->x
#initialize winning counts
0->winp1
0->winp2
#initialize banks
0->bankp1
0->bankp2
#initialize first time played
1->t
#initialize number of coins each player has at start
3->coinsp1
1->coinsp2
Lbl start
#initialize number of pennies each player has at the start
coinsp1->player1
coinsp2->player2
Lbl a
ClrIO
Disp player1, player2
Disp approx(winp1/t), approx(winp2/t)
Disp bankp1, bankp2
Disp t
#if someone wins
If player1=0: Goto b
If player2=0: Goto b
#the flip, 1 is heads
rand(2)-1->p1
rand(2)-1->p2
If p1=1: player2-1->player2
If p1=1: player1+1->player1
If p2=1: player1-1->player1
If p2=1: player2+1->player2
Goto a
Lbl b
If player2=0: winp1+1->winp1
If player2=0: bankp1+coinsp2->bankp1
If player2=0: bankp2-coinsp2->bankp2
If player1=0: winp2+1->winp2
If player1=0: bankp2+coinsp1->bankp2
If player1=0: bankp1-coinsp1->bankp1
t+1->t
bankp1->ep1[t]
t->x[t]
Goto start
EndPrgm
and the pic was obtained from graphing the points (x[t],ep1[t]), for t=1 to t=number of trials
digithead
17th September 2006, 01:12 AM
Example: One player has 3 pennies, and another player has only 1 penny. A fair coin is tossed every round to determine if a penny is won or lost for either player. The odds are 3/4 that player A (Who begins with 3 pennies) will win the game. This is entirely different than the martingale betting strategy, because only 1 penny is bet for each round of the game.
Because there are 3 ways player A may win, and only one way player B can win, player A has a concrete advantage. Player B, only wins in the event that the coin is tossed in his favor 3 times in a row, while player A can win on the first throw. Or he can win after losing the first coin toss, or he can win after losing the second coin toss. So the odds are 75% that he (or she) will win in this game.
I don't think you're conceptualizing the problem correctly and your initial probabilities are wrong given the information you've provided...
You have two players, one has three chances to win (i.e., 1 flip in his favor out of three) while the other needs three favorable flips in a row. I'm assuming independent trials hence player A's probability is p(x1=1 or x2=1 or x3=1)=p(x1=1)+p(x1=0 and x1=1)+p(x1=0 and x2=0 and x3=1)=.5+.5^2+.5^3=.875 while player B's probability is p(x1=1 and x2=1 and x3=1)=.5^3=.125. Note that player B winning intersects player A winning as player A wins on player B's first toss.
I'm assuming that both player A and player B can win at the same time. So from the gambler's ruin theorem we can calculate the probability that a player will go broke. The theorem gives us:
p(player A will go broke)=(1-r^(b))/(1-r^(a+b)) where r=p/(1-p), p=probability of a favorable outcome, a=player A's beginning fortune, and b=available winnings.
From this, we can easily see that any available winnings significantly greater than player A's assets make it nearly a certainty that player A will go broke...
Plugging in r=.875/.125=7, a=3 cents, b=100 dollars then p(player A will go broke)=94%
So if a pot is greater than 1000 dollars, it's nearly a certainty in this case that player A will go broke. One can also see that any pot over 11 cents and player b will go broke...
Some gamblers realized that it was inevitable for a player to go broke so this allows one to figure out the probability of winning a certain amount of money to figure out optimal stopping times. Hence, gambler's ruin is part of martingale theory. Markov chains are a related concept...
Sorry, but Vega$ is built on this principle, so unless you can figure out how to break the bank, it's inevitable that you will lose in the long run. Unless you're psychic, then you wouldn't need probability theory...
CoreyWhite
17th September 2006, 10:08 AM
If the computer model is accurate then I feel we should apply for the JREF challenge, and take the money before anyone begins to accept this as something in the common knowledge. Because right now it is paranormal.
8)
nathan
17th September 2006, 10:44 AM
If the computer model is accurate then I feel we should apply for the JREF challenge, and take the money before anyone begins to accept this as something in the common knowledge. Because right now it is paranormal
Ok then, please apply
HappyCat
17th September 2006, 01:39 PM
I see what I believe Corey is seeing, but I'm not sure if I'm just not running enough trials, or if my program is doing exactly what I want it to do for that matter.
I ran 2397 trials (that's just when I stopped my program), and graphed player 1's winnings (see attached pic), and while it dipped below the winnings = 0 line a few times, it never crosses it again after 673 trials.
Now maybe for some larger number of trials it comes back and maybe dips down to average out?
I decided to duplicate this experiment. Here is the results that I got.
http://img15.imgspot.com/?u=/u/06/259/15/graph1158520618.jpg (sorry for the labeling on the X axis, I couldn't figure out how to change that in Open Office. There are 10000 trials there, though)
After 10000 plays of the game, person A is ahead 20 pennies. Also, I don't understand part of your program.
rand(2)-1->p1
rand(2)-1->p2
If p1=1: player2-1->player2
If p1=1: player1+1->player1
If p2=1: player1-1->player1
If p2=1: player2+1->player2
In this, you are selecting 2 random numbers, and modifying player1 and player2 based on the outcome of those numbers. It seems selecting 2 numbers is unnecesary, because if p1 = p2, then the values remain unchanged. While this does mathematically come out to be correct (since it only adds a bunch of trials where money doesn't change hands), I think it would make more sense to say
rand(2)-1->coinflip
If coinflip = 1: player2-1->player2 else player2+1->player2
If coinflip = 1: player1+1->player1 else player1-1->player1
Ririon
17th September 2006, 01:50 PM
I decided to duplicate this experiment. Here is the results that I got.
...
I think it would make more sense to say
...
...and you should also have stopped about half way through... :p
CoreyWhite
17th September 2006, 03:33 PM
I also noticed something different about your program than my origonal experiment. It seems you are only testing 3 vs 1, and 1 vs 1. And you program isn't designed to run a chain reaction. You could do a test to see how far you can take these chain reactions on average. After you win 1 penny you just add it to the pile of 3, and repeat the experiment with 4 pennies. And do the same when you start with 1.
TobiasTheViking
17th September 2006, 03:45 PM
I also noticed something different about your program than my origonal experiment. It seems you are only testing 3 vs 1, and 1 vs 1. And you program isn't designed to run a chain reaction. You could do a test to see how far you can take these chain reactions on average. After you win 1 penny you just add it to the pile of 3, and repeat the experiment with 4 pennies. And do the same when you start with 1.
Just wondering, are you gonna take back your statement that Randi have stolen the 1 million dollars?
And are you going to properly apologize for making that blatant lie?
digithead
17th September 2006, 03:46 PM
TC & Happycat,
Correct me if I'm wrong here, but once a player's bankroll goes to 0, isn't the game is over? Any simulation should stop at that point...
Also, it's not clear from the original post if player A and player B are competing against each other or against some imaginary house. If they aren't competing, then by gambler's ruin, the house just needs a big enough bankroll to bankrupt each of them. If they are competing against each other, then by the same theorem, player A will beat player B everytime because he has both a higher bankroll and a higher probability than player B...
And trust me, there's nothing paranormal about this. It's just a mathematical exercise...
-digithead
HappyCat
17th September 2006, 03:56 PM
I also noticed something different about your program than my origonal experiment. It seems you are only testing 3 vs 1, and 1 vs 1. And you program isn't designed to run a chain reaction. You could do a test to see how far you can take these chain reactions on average. After you win 1 penny you just add it to the pile of 3, and repeat the experiment with 4 pennies. And do the same when you start with 1.
I would appreciate you showing how you arrived at person A having a 4/5ths chance of winning a round if person A starts with 4 pennies and person B starts with 1. I think that your reasoning is flawed when you say 3 pennies in person A's bank, 4 pennies over all, therefore 3/4 chance of winning. I agree with a 3/4ths probability of a win in this instance, but I think you used a flawed method to arrive at the correct answer. The way I see it, if A has 3 and B has 1, then on the first flip, A has a 50% chance of eliminating B. if A loses the first flip, then both players have the same number of pennies, and therefore the same chances of winning at that point, which is 50%. So 50% of the time player A wins right away, and of the cases where he does not win right away, he wins half of those too. Which would yield 75% chance of winning over all. I don't think the same argument can be made for A having 4 and B having 1, however, so if you don't mind, please show your work, so I can see how you arrived at your conclusion.
TC & Happycat,
Correct me if I'm wrong here, but once a player's bankroll goes to 0, isn't the game is over? Any simulation should stop at that point...
I was assuming that a running debt would be calculated over time. Otherwise, neither player could get larger than 4 pennies,and that isn't a very good experiment (since you are right, A's larger bank would mean that more often than not, A would end with 4 pennies and B would end with 0). The point of this experiment is to show that there is nothing paranormal going on here. The expected gain of either player is 0, which differs from what CoreyWhite is claiming, which is essentially that the probability of each successive coin flip is influenced by the previous flip. I would say that gaining only 20 cents in 10000 flips would be pretty unusual if A had some kind of significant advantage.
William Smith
17th September 2006, 03:57 PM
If the computer model is accurate then I feel we should apply for the JREF challenge, and take the money before anyone begins to accept this as something in the common knowledge. Because right now it is paranormal.
8)
CoreyWhite, please explain to the forum members what "is paranormal" about this.
Also, I'd like to hear your reply to TobiasTheCommie's questions in his last post.
CoreyWhite
17th September 2006, 05:49 PM
CoreyWhite, please explain to the forum members what "is paranormal" about this.
Also, I'd like to hear your reply to TobiasTheCommie's questions in his last post.
If you can't see what's paranormal about this challenge then there is something WRONG WITH YOU! 8)
And as for Tobias, James Randi sent me a letter saying he ran off with the million and some hot mamma. That's where the joke came from!
CoreyWhite
17th September 2006, 05:57 PM
Here is the e-mail:
I've just stolen the million dollars and run off to Latvia with Sophia
Loren, so I can't answer your e-mail...
James Randi.
digithead
17th September 2006, 06:20 PM
I would appreciate you showing how you arrived at person A having a 4/5ths chance of winning a round if person A starts with 4 pennies and person B starts with 1. I think that your reasoning is flawed when you say 3 pennies in person A's bank, 4 pennies over all, therefore 3/4 chance of winning. I agree with a 3/4ths probability of a win in this instance, but I think you used a flawed method to arrive at the correct answer. The way I see it, if A has 3 and B has 1, then on the first flip, A has a 50% chance of eliminating B. if A loses the first flip, then both players have the same number of pennies, and therefore the same chances of winning at that point, which is 50%. So 50% of the time player A wins right away, and of the cases where he does not win right away, he wins half of those too. Which would yield 75% chance of winning over all. I don't think the same argument can be made for A having 4 and B having 1, however, so if you don't mind, please show your work, so I can see how you arrived at your conclusion.
I was assuming that a running debt would be calculated over time. Otherwise, neither player could get larger than 4 pennies,and that isn't a very good experiment (since you are right, A's larger bank would mean that more often than not, A would end with 4 pennies and B would end with 0). The point of this experiment is to show that there is nothing paranormal going on here. The expected gain of either player is 0, which differs from what CoreyWhite is claiming, which is essentially that the probability of each successive coin flip is influenced by the previous flip. I would say that gaining only 20 cents in 10000 flips would be pretty unusual if A had some kind of significant advantage.
I think we're all tripped up by the incredibly poor description that CW gave in his original post describing his game so we're all making assumptions and imputing information at this point about what we think he meant...
Also, I agree with you that player A has a 50% chance of winning on his first toss. However to calculate his true probability of winning in the first round you need to add in the disjoint events of (toss1=0 and toss2=1) and (toss1=0 and toss2=0 and toss3=1) because there are three different ways player A can win which brings player A's probability of winning to 87.5%. The only way player a can win is if (toss1=1 and toss2=1 and toss3=1)...
And you're quite correct that this not paranormal. It's someone (CW) with an apparently poor grasp of mathematics and logic fooling themselves into thinking that they're clever...
And given his last post, I predict he'll soon be suspended then banned. Anybody want to lay odds on that?
T'ai Chi
17th September 2006, 07:56 PM
Also, I don't understand part of your program.
...
In this, you are selecting 2 random numbers, and modifying player1 and player2 based on the outcome of those numbers. It seems selecting 2 numbers is unnecesary, because if p1 = p2, then the values remain unchanged. While this does mathematically come out to be correct (since it only adds a bunch of trials where money doesn't change hands), I think it would make more sense to say
Yup, your way certainly makes more sense to do, thanks.
TobiasTheViking
18th September 2006, 01:09 AM
Here is the e-mail:
I've just stolen the million dollars and run off to Latvia with Sophia
Loren, so I can't answer your e-mail...
James Randi.
I'm going to inquiere as to whether or not that is a lie. Even if it isn't it is clearly a joke.
You never said if your withdraw your statement that he stole the million dollars.
You never made a proper appology, do you intend to?
TobiasTheViking
18th September 2006, 01:12 AM
Hm, considering that i doubt you have the investigation skills to come up with that message i think i will asume it is genuine. Certain aspects of it look to be genuine Randi.
It is still clearly a joke, and not a reason for the attack you made.
Also, when you were asked for evidence why didn't you supply the email?
CoreyWhite
18th September 2006, 09:34 AM
You need to take your medication Tobias, and it wouldn't hurt learning to play the piano either. For an autistic kid you should know that the computer isn't going to get you anywhere in life. It is just a forum, k?
CoreyWhite
18th September 2006, 11:26 AM
Here is my C source code for this program
-
#include <stdio.h>
#include <stdlib.h>
main()
{
/* DEFINE VARIABLES */
int seed; /* Choose any integer value for seed to initialize the random number generator with. The same value of seed will always produce the same sequence of random numbers. To get a different sequence of random numbers next time, choose a different value of seed.
Note: on Microsoft Visual C++ 6.0, if seed is negative than a seed value from the system clock is used. Also check for a randomize() function on your compiler. */
double r; /* random value in range [0,1) */
long int M; /* user supplied upper boundary */
double x; /* random value in range [0,M) */
int y; /* random integer in range [0,M) if M is an integer then range = [0,M-1] */
int z; /* random integer in range [1,M+1) if M is an integer then range = [1,M] */
int count; /* just a variable we need to count how many random numbers we've made for this example */
/*BEGIN CODE*/
seed = 10000; /* choose a seed value */
srand(seed); /*initialize random number generator*/
M = 2; /* Choose M. Upper bound */
int score=0;
int games=0;
int beans1 = 0;
for(int cnt=0; cnt<10000; cnt++){
int count=0;
beans1 = 3 + score;
int beans2 = 1;
while(beans1!=0 && beans2!=0)
{
r = ( (double)rand() / ((double)(RAND_MAX)+(double)(1)) );
/* r is a random floating point value in the range [0,1) {including 0, not including 1}. Note we must convert rand() and/or RAND_MAX+1 to floating point values to avoid integer division. In addition, Sean Scanlon pointed out the possibility that RAND_MAX may be the largest positive integer the architecture can represent, so (RAND_MAX+1) may result in an overflow, or more likely the value will end up being the largest negative integer the architecture can represent, so to avoid this we convert RAND_MAX and 1 to doubles before adding. */
x = (r * M);
/* x is a random floating point value in the range [0,M) {including 0, not including M}. */
y = (int) x;
/* y is a random integer in the range [0,M) {including 0, not including M}. If M is an integer then the range is [0,M-1] {inclusive} */
z = y + 1;
/* z is a random integer in the range [1,M+1) {including 1, not including M+1}. If M is an integer then the range is [1,M] {inclusive} */
if(z==1){
beans1=beans1++;
beans2=beans2--;
}
if(z==2){
beans1=beans1--;
beans2=beans2++;
}
count++;
}
if(beans1>beans2){
score++;
games++;
}
if(beans1<beans2){
printf("%d %d\n",score+3, games);
score=0;
games=0;
}
}
}
CoreyWhite
18th September 2006, 11:34 AM
http://grimoire.genesismuds.com/output.txt
Is some sample output from my program
William Smith
18th September 2006, 12:23 PM
If you can't see what's paranormal about this challenge then there is something WRONG WITH YOU! 8)
...
Perhaps. Would you please explain it (reminder: the "paranormal" aspect of "this challenge") to me anyway, CoreyWhite? I'm eager to learn.
CoreyWhite
18th September 2006, 12:42 PM
Well if a psychic has ESP and is using his powers to predict things, this program shows a way you can have a statistical advantage at doing this which is outside normal understanding.
I've uploaded a formatted verstion of my code, that is much easier on the eyes. Here:
Here is my C source code for this program
-
#include <stdio.h>
#include <stdlib.h>
main()
{
double r;
long int M;
double x;
int y;
int z;
int count;
seed = 10000;
srand(seed);
M = 2;
int score=0;
int games=0;
int beans1 = 0;
for(int cnt=0; cnt<10000; cnt++){
int count=0;
beans1 = 3 + score;
int beans2 = 1;
while(beans1!=0 && beans2!=0)
{
r = ( (double)rand() / ((double)(RAND_MAX)+(double)(1)) );
x = (r * M);
y = (int) x;
z = y + 1;
if(z==1){
beans1=beans1++;
beans2=beans2--;
}
if(z==2){
beans1=beans1--;
beans2=beans2++;
}
count++;
}
if(beans1>beans2){
score++;
games++;
}
if(beans1<beans2){
printf("%d %d\n",score+3, games);
score=0;
games=0;
}
}
}
HappyCat
18th September 2006, 12:42 PM
A friend and I have been doing some thinking about this problem. Here is the work we did. I am not entirely clear on the game you would like to play, so we said this:
Person A has x pennies and person B has y pennies. A fair coin is flipped, and if the coin is heads, A gives a penny to B, otherwise B gives a penny to A. What is the probability that A will bankrupt B first?
Define P(N,K) (with 0 <= K <= N) to represent the probability that A will win given that there is N total pennies, and A has K of them.
P(N, 0) = 0 for all N, because A is immediately bankrupt
P(N, N) = 1 for all N, because B is immediately bankrupt
Because A has a .5 chance to gain a penny and a .5 chance to lose a penny:
P(N, K) = .5*P(N, K-1) + .5*P(N, K+1)
multiply both sides by 2
2*P(N, K) = P(N, K-1) + P(N, K+1)
P(N, K) + P(N, K) = P(N, K-1) + P(N, K+1)
P(N, K) + P(N, K) - P(N, K-1) = P(N, K+1)
P(N, K) - P(N, K-1) = P(N, K+1) - P(N, K)
From this final result, we can see that the difference between any two adjacent values of K is always a constant. Since there are N values between P(N, N) and P(N, 0), and P(N, N) - P(N, 0) = 1, each successive value increases by 1/N. So P(N, 1) = 1/N, P(N, 2) = 2/N, ... P(N, K) = K/N.
So, if you had your 500,000 pennies, and Randi had 100,000,000 pennies, and you were to play this game, your chances of winning are 500,000 / 100,500,000 = 5/1005 = 1/201. Playing this game, you would probably only win Randi's million dollars once every 201 times you played. Which means that your expected outcome is 1,000,000 * 1/201 - 5,000 * 200/201 = 4975.124378109 - 4975.124378109 = 0. So, as we would expect, since you have an equal probability of gaining or losing 1 penny each round, the expected outcome is 0. Winning a game where you win about 1 in 201 would be unusual, but not special enough to be considered paranormal. Try going in with 50$ in pennies instead. If you can use some paranormal ability to beat 1/20001 odds, I will be impressed.
Bindamel
18th September 2006, 12:55 PM
Well if a psychic has ESP and is using his powers to predict things, this program shows a way you can have a statistical advantage at doing this which is outside normal understanding.
I've uploaded a formatted verstion of my code, that is much easier on the eyes. Here:
Here is my C source code for this program
....[Initial stuff removed for brevity -- Bindy]
for(int cnt=0; cnt<10000; cnt++){
int count=0;
beans1 = 3 + score;
int beans2 = 1;
If I'm not mistaken, what you're attempting to simulate here is beginning with 3 beans against an opponent with one. If you win, you then put your four beans up against another opponent with one. Correct, Corey?
while(beans1!=0 && beans2!=0)
{
r = ( (double)rand() / ((double)(RAND_MAX)+(double)(1)) );
x = (r * M);
y = (int) x;
z = y + 1;
if(z==1){
beans1=beans1++;
beans2=beans2--;
}
if(z==2){
beans1=beans1--;
beans2=beans2++;
}
count++;
}
The way the game plays out seems extra complex to me, but not wrong, so I'm okay with this.
if(beans1>beans2){
score++;
games++;
}
beans1>beans2 means you won, so you increase the score by one, so next time through you'll be putting one more bean in against your opponent's single bean.
if(beans1<beans2){
printf("%d %d\n",score+3, games);
score=0;
games=0;
}
}
}
Herein lies the rub, as they say. You output the results after you lose. Your simulation only arrives here if all of your beans have been won by your opponent. You then print out how many beans you would have won, if you had played one fewer round than you actually did.
In reality, the output of the simulation would only be accurate if you placed the print statement after the score=0 statement. :eek:
Aside: Are you actually suggesting that this whole exercise is about precognition now? If you have ESP, you can play anything and win.
nathan
18th September 2006, 01:13 PM
if(z==1){
beans1=beans1++;
beans2=beans2--;
}
if(z==2){
beans1=beans1--;
beans2=beans2++;
}
This code is undefined. your results are therefore meaningless.
CoreyWhite
18th September 2006, 01:25 PM
Here is the update, I did have a bug.
Here is my C source code for this program
-
#include <stdio.h>
#include <stdlib.h>
main()
{
double r;
long int M;
double x;
int y;
int z;
int count;
seed = 10000;
srand(seed);
M = 2;
int score=0;
int games=0;
int beans1 = 0;
for(int cnt=0; cnt<10000; cnt++){
int count=0;
beans1 = 3 + score;
int beans2 = 1;
while(beans1!=0 && beans2!=0)
{
r = ( (double)rand() / ((double)(RAND_MAX)+(double)(1)) );
x = (r * M);
y = (int) x;
z = y + 1;
if(z==1){
beans1=beans1++;
beans2=beans2--;
}
if(z==2){
beans1=beans1--;
beans2=beans2++;
}
count++;
}
if(beans1>score+3){
score++;
games++;
}
if(beans1<=0){
printf("%d %d\n",score+3, games);
score=0;
games=0;
}
}
}
nathan
18th September 2006, 01:27 PM
Here is the update, I did have a bug.
Your code is still undefined.
HappyCat
18th September 2006, 01:28 PM
This code is undefined. your results are therefore meaningless.
Actually, it is silly, not meaningless. (beans--) returns (beans - 1), and also stores (beans - 1) into beans. So basically, if beans is 5, then (beans--) causes beans to be set to 4, then returns 4, which is then stored into beans. For example:
#import <stdio.h>
int main(int argc, char** argv)
{
int x = 1;
x = x++;
printf("%d\n", x);
}
will print 2.
drkitten
18th September 2006, 01:33 PM
Actually, it is silly, not meaningless. (beans--) returns (beans - 1), and also stores (beans - 1) into beans. So basically, if beans is 5, then (beans--) causes beans to be set to 4, then returns 4, which is then stored into beans.
er, no.
Your example, simplified :
int x=1;
x = x++;
Is indeed "meaningless" (more technically, "implementation-defined"). The expression "x--" does nto return x-1, but x. (And similarly, x++ returns x itself, not x+1. ) The compiler is at liberty to perform the assignment or the increment operation or some wierd combination of both. The final value of x could be -- literally -- anything, although 1, 2, and 3 are the most likely choices.
nathan
18th September 2006, 01:41 PM
Actually, it is silly, not meaningless. (beans--) returns (beans - 1), and also stores (beans - 1) into beans.
Incorrect in two points.
1) beans-- returns beans.
2) beans = beans--; is modifying an lvalue more than once without an intervening sequence point.
Once your program has invoked undefined effects, it is meaningless to speculate as to what it might mean from a correctness point of view.
Please believe me when I claim it is undefined. I am a compiler engineer. I don't have a C std infront of me right now, so can't point you at the relevent section of the C std.
HappyCat
18th September 2006, 01:42 PM
I think I fully understand the logical fallacy that you are using, CoreyWhite. You see that if you have 500,000 pennies vs. Randi's 1, you have some pretty overwhelming odds of winning. So you think, when you win the first one, you put it in your pile, and Randi draws another penny out of his pile, and you play him 500,001 to 1. This method of thinking of the problem creates a false sense that as long as Randi is playing against you with 1 penny, then you will somehow have better odds of winning. This is not true. Try thinking of the problem like this: Randi has 1 penny, and you have 500,000. If you win, you can add Randi's penny to your pile. If Randi wins, he throws it back into his bank of 100,000,000 and plays you again with only one penny. So, if the game starts out as (500,000 - 1), there is a 50% probability that the game will change to (499,999 - 1) and a 50% probability that the game will change to (500,001 - 1). So if we display the game states on a line, like so:
(0 - 1)
(1 - 1)
(2 - 1)
...
(499,997 - 1)
(499,998 - 1)
(499,999 - 1)
(500,000 - 1)
(500,001 - 1)
(500,002 - 1)
(500,003 - 1)
...
(100,499,997 - 1)
(100,499,998 - 1)
(100,499,999 - 1)
(100,500,000 - 1)
Each round you play, you will either move up one game state or down one game state, since Randi will always throw any penny he wins into his bank. Do you see that there is a 50% chance of moving up one game state and 50% chance that you will move down one game state each round you play? Do you see that you need to move down 100 million times to beat Randi? Do you see that if you move up 500,000 times you will lose to Randi? Moving up and down randomly, it is far more likely that you will move up 500,000 places from your starting position before you move down 100 million places from your starting position. In fact, as stated from the math in my above post, the probability is 200/201 that you will lose. I am sorry, but your method of obscuring the problem does not change the mathematical probability of a victory.
CoreyWhite
18th September 2006, 01:43 PM
Unless you can analyize what the program is doing in a way people reading you can understand you would be better off not responding with anoying comments. Because my program does work as advertised. I can't debate you about comments like "your program is undefined", because they are meaningless. The program doesn't produce any undefined output at all.
drkitten
18th September 2006, 01:46 PM
Unless you can analyize what the program is doing in a way people reading you can understand you would be better off not responding with anoying comments. Because my program does work as advertised.
No, it doesn't.
Basically, you made an error that was too subtle for a typical compiler to catch.
The program doesn't produce any undefined output at all.
That's right. Neither the compiler program nor you are smart enough to recognize that the outputs it gets are the process of an indeterminate calculation. So the program gives you numbers, without either knowing or caring whether or not they are meaningful, accurate, or correct.
Nathan, on the other hand, is smart enough to recognize that.
nathan
18th September 2006, 01:52 PM
Is indeed "meaningless" (more technically, "implementation-defined").
no, it's undefined. Implementation defined is something different.
drkitten
18th September 2006, 01:52 PM
no, it's undefined. Implementation defined is something different.
I stand corrected.
HappyCat
18th September 2006, 02:10 PM
Incorrect in two points.
1) beans-- returns beans.
2) beans = beans--; is modifying an lvalue more than once without an intervening sequence point.
Once your program has invoked undefined effects, it is meaningless to speculate as to what it might mean from a correctness point of view.
Please believe me when I claim it is undefined. I am a compiler engineer. I don't have a C std infront of me right now, so can't point you at the relevent section of the C std.
http://www.cppreference.com/operator_precedence.html
According to the c++ operator preference, the post-increment operator takes precidence in a statement before the assignment, and therefore it is well defined within the c++ standard that the post-increment will always be executed first, and that the output of this will always be 2. I am willing to admit I am wrong if someone can show me the C spec and show me that the order of operations in this respect is truely undefined. I am sorry. I do respect your expertise as a compiler engineer, but I can not bow to an appeal to authority.
CoreyWhite
18th September 2006, 02:18 PM
Here is my C source code for this program (with comments)
-
#include <stdio.h> //Initialize headers
#include <stdlib.h>
main()
{ //Initialize variables
double r;
long int M;
double x;
int y;
int z;
int count;
seed = 10000;
srand(seed); //Seed the random number generator
M = 2;
int score=0; //Score keeps track of the number of beans won every game
int games=0; // games keeps track of the number of games we have played before losing all of the beans, which is equal to score.
int beans1 = 0; // Initial value set to zero and defined within the loop
for(int cnt=0; cnt<10000; cnt++){ // We play 10,000 rounds
int count=0;
beans1 = 3 + score; // Beans gets defined here, as starting with 3 beans, and having a 0 bonus score (It changes as you win more beans per round)
int beans2 = 1; // The program attempts to win just one bean for every game.
while(beans1!=0 && beans2!=0) // The battle begins
{
r = ( (double)rand() / ((double)(RAND_MAX)+(double)(1)) );
x = (r * M);
y = (int) x;
z = y + 1; // A coin is flipped and is either 1 or 2 in value
if(z==1){ // Heads wins.
beans1=beans1++; // Beans1 gains one bean from Beans2
beans2=beans2--;
}
if(z==2){ // Tails loses
beans1=beans1--; // Beans2 gains one bean from Beans1
beans2=beans2++;
}
count++; // We keep track of the number of rounds in the battle
}
if(beans1>score+3){ // If beans1 is greater than the initial value of beans plus the total number of beans that have been won so far in this game, then the score goes up, and we go on to the next game. We check this at the end of every game.
score++;
games++;
}
if(beans1<=0){ //If beans1 has lost the game and doesn't have anymore beans then we know the game is over, so we reset score, and reset games.
printf("%d %d\n",score+3, games); // And we print out the total number of games played on this trial and show the total score plus the initial value of beans.
score=0;
games=0;
}
}
}
nathan
18th September 2006, 02:20 PM
http://www.cppreference.com/operator_precedence.html
According to the c++ operator preference, the post-increment operator takes precidence in a statement before the assignment, and therefore it is well defined within the c++ standard that the post-increment will always be executed first, and that the output of this will always be 2. I am willing to admit I am wrong if someone can show me the C spec and show me that the order of operations in this respect is truely undefined. I am sorry. I do respect your expertise as a compiler engineer, but I can not bow to an appeal to authority.
Operator precedence tells you how the expression will be parsed. I.e.
i = i++
is parsed as
i = (i++)
and not
(i = i)++
Precedence will not tell you about order of evaluation. btw, C & C++ are the same in this regard. You're making a classic error in claiming that 'my compiler does X', that is an invalid argument when it comes to what the std means. In the C++ std IIRC you need to look somewhere in clause 3 or the beginning of clause 5 about this kind of thing.
http://c-faq.com/expr/index.html should tell you about why i = i++ is undefined, and why it is pointless trying to determine what it means.
ETA C++ std, not C std
Bindamel
18th September 2006, 02:22 PM
Hey Corey,
Can you try running your program with the changes these folks are talking about?
beans1=beans1++; should be
beans1++;
beans2=beans2--; should be
beans2--;
beans1=beans1--; should be
beans1--;
and
beans2=beans2++; should be
beans2++;
I think that's what there saying, my programming knowledge is limited to various forms of BASIC, honestly.
Looking at your output file, I personally think it's running correctly (at least you lost on the first round 25.5% of the time, as expected), but this way we can get past the programming issues and work on the probability issues.
HappyCat
18th September 2006, 02:37 PM
Operator precedence tells you how the expression will be parsed. I.e.
i = i++
is parsed as
i = (i++)
and not
(i = i)++
Precedence will not tell you about order of evaluation. btw, C & C++ are the same in this regard. You're making a classic error in claiming that 'my compiler does X', that is an invalid argument when it comes to what the std means. In the C++ std IIRC you need to look somewhere in clause 3 or the beginning of clause 5 about this kind of thing.
http://c-faq.com/expr/index.html should tell you about why i = i++ is undefined, and why it is pointless trying to determine what it means.
ETA C++ std, not C std
I apologize, I was wrong.
CoreyWhite
18th September 2006, 02:41 PM
Problem fixed and new output uploaded to http://grimoire.genesismuds.com/output.txt
Here is my C source code for this program
-
#include <stdio.h>
#include <stdlib.h>
main()
{
double r;
long int M;
double x;
int y;
int z;
int count;
seed = 10000;
srand(seed);
M = 2;
int score=0;
//Score keeps track of the number of beans won every game
int games=0;
// games keeps track of the number of games we have played before losing all of the beans, which is equal to score.
int beans1 = 0;
// Initial value set to zero and defined within the loop
for(int cnt=0; cnt<10000; cnt++){
// We play 10,000 rounds
int count=0;
beans1 = 3 + score;
// Beans gets defined here, as starting with 3 beans, and having a 0 bonus score (It changes as you win more beans per round)
int beans2 = 1;
// The program attempts to win just one bean for every game.
while(beans1!=0 && beans2!=0)
// The battle begins
{
r = ( (double)rand() / ((double)(RAND_MAX)+(double)(1)) );
x = (r * M);
y = (int) x;
z = y + 1;
// A coin is flipped and is either 1 or 2 in value
if(z==1){
// Heads wins.
beans1++;
// Beans1 gains one bean from Beans2
beans2--;
}
if(z==2){
// Tails loses
beans1--;
// Beans2 gains one bean from Beans1
beans2++;
}
count++;
// We keep track of the number of rounds in the battle
}
if(beans1>score+3){
// If beans1 is greater than the initial value of beans plus the total number of beans that have been won so far in this game, then the score goes up, and we go on to the next game. We check this at the end of every game.
score++;
games++;
}
if(beans1<=0){
//If beans1 has lost the game and doesn't have anymore beans then we know the game is over, so we reset score, and reset games.
printf("%d %d\n",score+3, games);
// And we print out the total number of games played on this trial and show the total score plus the initial value of beans.
score=0;
games=0;
}
}
}
Bindamel
18th September 2006, 02:48 PM
int games=0;
// games keeps track of the number of games we have played before losing all of the beans, which is equal to score.
Okay, now you've lost me. How does this show that you have an advantage in this game? You're saying here that you recognize that you will eventually lose all your beans!
CoreyWhite
18th September 2006, 03:37 PM
Sure you lose eventually but more often than not you make one bean or more. The odds go up exponentially with each extra bean you decide to start gambling with.
TobiasTheViking
18th September 2006, 03:47 PM
You need to take your medication Tobias
Why the personal attack?
, and it wouldn't hurt learning to play the piano either.
Why?
For an autistic kid you should know that the computer isn't going to get you anywhere in life.
Thats just bull.
It is just a forum, k?
Yeah, and you are a bad person.
Bindamel
18th September 2006, 05:16 PM
Sure you lose eventually but more often than not you make one bean or more. The odds go up exponentially with each extra bean you decide to start gambling with.
So what is your advantage against the house then? When do you stop playing? You should try to adjust your simulation to show that you actually come out ahead in the long run.
petre
18th September 2006, 05:25 PM
Following the first line output:
46 43
This means that player 1 started at 3 beans and player 2 started at 1 bean and player 1 won and got all 4 beans (had player 1 lost, the output would have been 3 0). Then player 1 played with 4 beans and player 2 played with 1 bean, and player 1 won again to move to 5 beans (again, otherwise the output would have been 4 1). This continued until player 1 reached 46 beans after 43 games. During that round, player 2 won and got the 46 beans (right?) 43 of which he had put into the pot to begin with. That puts player 2 up 3 beans total after 44 games. Then there's another output:
5 2
That means player 1 managed to win the next two games (getting back to down only 1 bean total) before player 2 again won, ending up a total of 6 ahead.
Adding the 2nd column, it seems that player 1 won a total of 9394 games that were eventually follwed by a win for player 2. There were 603 outputs, so that's 603 wins for player 2. That totals 9997 recorded wins, which means player 1 must have won 3 more times in those 10,000 trials. Player's 2 603 wins are worth a net gain of 3 beans each, for a total of 1809 beans, minus player 1's final 3 wins gives an overall gain for player 2 of 1806 over all the runs.
Wasn't the intent to be the person adding more coins each round to increase his winnings? He just lost 1806 coins with that strategy (assuming he really did stop after the 10,000 trials).
Now, this is just one run of the program. It's possible it could have terminated and output nothing at all. In that case, player 1 would come out ahead 10,000 beans. Or something like "3 0" could have come up, meaning player 2 won the 1st round (up 3 beans) and then lost the other 9999 games for a net win of 9996 beans for player 1, or "4 1" giving 9994, etc. My guess is that over numerous trials, the amount player 2 ends up ahead will balance with the amount player 1 ends up ahead. Sometimes player 1 will have a good run at the end and win a lot, other times player 2 will never let player 1 get too far. The limits are 10,000 beans for player 1 and 30,000 beans for player 2 (with the odds greatly varied between those two limits).
I reduced the program above to a simpler version that I believe will give the same results:
#include <stdio.h>
#include <stdlib.h>
main(){
int flip;
int player_1_beans;
int score = 0; // Score keeps track of the number of beans won for player 1 in the current game
srand(10000); // seed rng
for(int count = 0; count < 10000; count++){ // We play 10,000 rounds
player_1_beans = score + 3; // starts with 3 beans when score is 0
while(player_1_beans > 0 && player_1_beans < score + 4){ // The battle begins
y = (int) (( (double)rand() / ((double)(RAND_MAX)+(double)(1)) ) * 2); // A coin is flipped and is either 0 or 1 in value
if(flip == 0){ // Heads wins.
player_1_beans++; // Player 1 gains one bean from Player 2
}
else{ // Tails loses
player_1_beans--; // Player 2 gains one bean from Player 1
}
}
if(player_1_beans == score + 4){ // >= would work fine too
score++;
}
else{
printf("%d\n", score); // total beans player 1 got to is score + 3
score = 0;
}
}
}
CoreyWhite
18th September 2006, 06:32 PM
/*Try fixing this program up, because I couldn't get yours to run*/
#include <stdio.h>
#include <stdlib.h>
main()
{
double r;
long int M;
double x;
int y;
int z;
int count;
int seed = 10000;
srand(seed);
M = 2;
int score=0;
//Score keeps track of the number of beans won every game
int games=0;
// games keeps track of the number of games we have played before
//losing all of the beans, which is equal to score.
int beans1 = 0;
// Initial value set to zero and defined within the loop
int wins = 0;
int lost = 0;
int quit = 0;
int init = 0;
printf( "Initial Beans: ");
scanf("%d",&init);
printf("Stop after winning X number of beans: ");
scanf("%d",&quit);
for(int cnt=0; cnt<10000; cnt++){
// We play 10,000 rounds
int count=0;
beans1 = init + score;
// Beans gets defined here, as starting with 3 beans, and having a 0
//bonus score (It changes as you win more beans per round)
int beans2 = 1;
// The program attempts to win just one bean for every game.
while(beans1!=0 && beans2!=0)
// The battle begins
{
r = ( (double)rand() / ((double)(RAND_MAX)+(double)(1)) );
x = (r * M);
y = (int) x;
z = y + 1;
// A coin is flipped and is either 1 or 2 in value
if(z==1){
// Heads wins.
beans1=beans1++;
// Beans1 gains one bean from Beans2
beans2=beans2--;
}
if(z==2){
// Tails loses
beans1=beans1--;
// Beans2 gains one bean from Beans1
beans2=beans2++;
}
count++;
// We keep track of the number of rounds in the battle
}
if(beans1>score+init){
// If beans1 is greater than the initial value of beans plus the total
//number of beans that have been won so far in this game, then the score
//goes up, and we go on to the next game. We check this at the end of
//every game.
score++;
games++;
}
if(beans1<=0){
//If beans1 has lost the game and doesn't have anymore beans then we
//know the game is over, so we reset score, and reset games.
printf("Lost at: %d beans , %d games.\n",score+init, games);
// And we print out the total number of games played on this trial and
//show the total score plus the initial value of beans.
lost++;
score=0;
games=0;
}
if(score>=quit){
wins++;
printf("Won at: %d beans , %d games.\n",score+init,games);
beans1==0;
score=0;
games=0;
}
}
printf("Total Won: %d/%d\n",wins,wins+lost);
}
HappyCat
18th September 2006, 06:54 PM
Sure you lose eventually but more often than not you make one bean or more. The odds go up exponentially with each extra bean you decide to start gambling with.
No. Please read the math I posted above. It demonstrates that the odds go up and down linearly, Not exponentially. And that you have a 200/201 chance of losing your 5000$ with this method. Your expected gain is 0.
CoreyWhite
18th September 2006, 07:05 PM
Compile the source code I just posted, or at least read through it. It allows you to specify the initial number of pennies you want to play with and the number of pennies you want to try to win before you quit.
If you start with 5,000 and only try to win 1 penny at a time. The program wins 10,000 / 10, 000 . So every single time!
Which means if I go after one of his pennies with 5,000, I can do it at least 10,000 times without losing any of mine!
HappyCat
18th September 2006, 07:31 PM
If you have 5000 pennies and Randi has 1, you will win 5000 out of 5001 times. In the spirit of writing programs to prove things instead of using math, here it is:
import std.random;
import std.stdio;
const int GAMES_PLAYED = 1000000;
bool playgame(int p1, int p2)
{
while(p1 != 0 && p2 != 0)
{
if((rand()%2) == 1){p1++; p2--;}
else{p1--;p2++;}
}
return (p2 == 0);
}
void main()
{
int wins = 0;
int total = 0;
for(int x = 0; x < GAMES_PLAYED; x++)
{
if(playgame(5000, 1))
wins++;
total++;
writef("wins: %d/%d, or %f\n", wins, total, cast(float)(wins) / cast(float)(total));
}
}
This code produced this result when I stopped it because it was taking too long:
wins: 573408/573532, or 0.999784
5000/5001 wins is .9998. Please tell me what is wrong with my math if you disagree with it.
CoreyWhite
18th September 2006, 07:38 PM
I'm not saying your math is wrong, but even if it is right, expected deviation should tell us you could do that at least 3 or 4 times, without ever losing. It isn't always 5000/5001
HappyCat
18th September 2006, 08:04 PM
You are correct, you will not win exactly 5000 out of 5001 games. It is only a probability. It describes what is probably going to happen. I am sorry that I am unable to help you. I tried mathematically proving that your method does not offer an advantage, I tried offering an intuitive explanation of what is occuring, and I tried writing a program to demonstrate it as well. If you are simply relying on chance to help you beat the odds, then this is not paranormal. If you possess some ability that will give you an edge in this game, such as the ability to predict a coin flip before it occurs, then your ability, not your method, is paranormal.
CoreyWhite
18th September 2006, 08:47 PM
You are supporting an argument for ONE KIND OF VALUE.
There are other kinds of Value. For example if you only had one bean, and wanted to risk it to win another bean. Would you want to gamble with it?
Okay, probably not. But if you had a million beans and wanted to win one more bean. Would you be willing to risk 5000 beans to win that one bean? The odds as you say are 5000/5001. And the expected value for both games is exactly the same.
So because the values as you support them are equal when playing with one bean or 5000, and the odds are better with 5000. You should play that game correct? presuming you have 5000 to gamble with.
HeyLeroy
18th September 2006, 09:41 PM
A million beans? That would amount to quite a hill.
If you're so certain about your system, why not break Vegas?
Oh, and what about that slander thingy?
digithead
18th September 2006, 10:15 PM
Good lord, I leave for a day to do real work and I come back to see this devolve into a dueling c++ battle...
Regardless of the fine code posted here, gambler's ruin theorem is what you're all trying simulate. Basically, a gambler always wants to win so he searches for a system which would break the bank. But what gambler's ruin tells us that even in a fair game, the house is sure to beat the player if the house has an unlimited amount of money to commit. This is the principle that underlies all casino games...
One of the more counterintuitive points of gambler's ruin is that bold play or doubling down has a higher probability of winning than weak play or playing a percentage of your bank. Of course, bold play is more likely to exit the game quicker...
But something that is counterintuitive is not paranormal. Nor is a poor grasp of mathematics and logic, Mr. White...
nathan
19th September 2006, 03:45 AM
I apologize, I was wrong.
Happy to inform. And now I'm at my desk I can point you at section 6.5 paragraph 2 of the C99 std. 'Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be read only to determine the value to be stored.' I'm sorry I have to appeal to the authority of the std through -- I don't see a way out of that one :)
We now return to the task of learning about the gambler's ruin theory.
Cuddles
19th September 2006, 04:12 AM
Can this thread be moved out of the challenge?
Even if we assume that Corey has somehow discovered a way of winning at gambling there would still be nothing paranormal involved, it is just probability.
Mashuna
19th September 2006, 04:31 AM
Happy to inform. And now I'm at my desk I can point you at section 6.5 paragraph 2 of the C99 std. 'Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be read only to determine the value to be stored.' I'm sorry I have to appeal to the authority of the std through -- I don't see a way out of that one :)
We now return to the task of learning about the gambler's ruin theory.
I don't think it's an appeal to authority fallacy when you're appealing to the correct authority :)
William Smith
19th September 2006, 04:55 AM
Can this thread be moved out of the challenge?
Even if we assume that Corey has somehow discovered a way of winning at gambling there would still be nothing paranormal involved, it is just probability.
If you can't see what's paranormal about this challenge then there is something WRONG WITH YOU! 8)
...
:D
(If you want this thread moved, PM a Mod.)
CoreyWhite
19th September 2006, 10:27 AM
Please address the following facts about my program:
When I run 5 pennies and try to go after either 1, 2, 3, 4, or 5 at a time here are the probabilities of winning:
5:1 83.5%
5:2 71.6%
5:3 62.6%
5:4 56.1%
5:5 50%
But if I were to just go after one penny at a time with a pile of 5 every time here are the probabilities:
5:1 X 5:1 = 69%
5:1 X 5:1 X 5:1 = 58%
5:1 X 5:1 X 5:1 X 5:1 = 48%
5:1 X 5:1 X 5:1 X 5:1 X 5:1 = 40%
Now Which game has better luck?
CoreyWhite
19th September 2006, 11:34 AM
Here is the latest version of my source code, for you to compile and experiment with.
. #include <stdio.h>
. #include <stdlib.h>
.
.
. main ()
. {
. double r;
. long int M;
. double x;
. int y;
. int z;
. int count;
.
.
. int seed = 10000;
. srand (seed);
. M = 2;
.
.
. int score = 0;
.
. //Score keeps track of the number of beans won every game
.
.
. int games = 0;
.
. // games keeps track of the number of games we have played before
. //losing all of the beans, which is equal to score.
.
.
. int beans1 = 0;
.
. // Initial value set to zero and defined within the loop
.
. int wins = 0;
. int lost = 0;
. int quit = 0;
. int init = 0;
.
. printf ("Initial Beans: ");
. scanf ("%d", &init);
. printf ("Stop after winning X number of beans: ");
. scanf ("%d", &quit);
.
. for (int cnt = 0; cnt < 10000; cnt++)
. {
. // We play 10,000 rounds
.
.
. int count = 0;
. beans1 = init + score;
.
. // Beans gets defined here, as starting with 3 beans
. // and having a 0 bonus score (It changes as you
. // win more beans per round)
.
.
. int beans2 = 1;
.
. // The program attempts to win just one
. // bean for every game.
.
.
. while (beans1 != 0 && beans2 != 0)
.
. // The battle begins
.
.
. {
. r = ((double) rand () / ((double) (RAND_MAX) + (double) (1)));
.
.
. x = (r * M);
. y = (int) x;
.
. z = y + 1;
.
. // A coin is flipped and is either 1 or 2 in value
.
. if (z == 1)
. {
. // Heads wins.
.
. beans1++;
.
. // Beans1 gains one bean from Beans2
.
. beans2--;
. }
. if (z == 2)
. {
. // Tails loses
.
. beans1--;
.
. // Beans2 gains one bean from Beans1
.
. beans2++;
. }
.
. count++;
.
. // We keep track of the number of rounds in the battle
.
. }
.
.
. if (beans1 > score + init)
. {
. // If beans1 is greater than the initial value
. // of beans plus the total number of beans
. // that have been won so far in this game, then
. // the score goes up, and we go on to the next
. // game. We check this at the end of every game.
.
. score++;
.
. games++;
. }
.
. if (beans1 <= 0)
. {
. //If beans1 has lost the game and doesn't
. //have anymore beans then we know the
. //game is over, so we reset score, and reset
. //games.
.
.
. printf ("Lost at: %d beans , %d games.\n", score + init, games);
.
. // And we print out the total number of
. // games played on this trial and show the
. // total score plus the initial value of beans.
.
. lost++;
. score = 0;
. games = 0;
.
. }
.
. if (score >= quit)
. {
. wins++;.
.
. printf ("Won at: %d beans , %d games.\n", score + init, games);
.
. beans1 == 0;
. score = 0;
. games = 0;
.
. }
.
. }
.
. printf ("Total Won: %d/%d\n", wins, wins + lost);
.
. }
petre
19th September 2006, 12:04 PM
I forgot to replace one "y" with "flip" in the code I posted earlier.
Anyway, I ran your code with a start of 3 beans, and a target of 10. There were 484 wins and 1609 losses. Each win was a net gain of 10 beans (it ended up with 13 total, which included the initial 3), so 4840 beans were won. Each loss was a net loss of 3 beans (the original 3 bet) so 4827 beans were lost. On this first run, you're up 13 beans. That doesn't seem too statistically significant for 10,000 flips.
I reran the same program for a start of 3 beans and a target of 5000. You lost 655 times and never won. Therefore you lost 1965 beans.
I then modified the program to run 10,000,000 games instead of 10,000. I ran it once more, again starting with 3 beans each time with a target of 5000. You won your 5000 beans 273 times, for winnings of 1,365,000 beans. You lost your 3 beans 443323 times for a loss of 1,329,969 beans. In this trial, you ended up 35,031 beans.
I changed to a seed of 8956 and ran that simulation again (3, 5000 for 10 million games). This time you managed only 267 wins for 1335000 in winnings and lost 434032 times for a loss of 1302096. For this trial, you ended up ahead 32,904 beans.
Then I changed the seed again to 12345 and ran the simulation again but with 100 million games (I like having a fast processor). You won 2642 games for 13210000 beans, lost 4401386 games for 13204158 beans, with a net win of 5842 beans.
It seems you can end up ahead some, or behind some, but never get too far one way or the other even after millions of games.
Here's another way to look at it. You start with 10 coins, and your opponent starts with 10 coins and you'll play 3 at a time and "keep your winnings" when you get 4 (a total of 7). In the simple case, you'd both put up just 1 bean at a time. Let's call the sets A (your pile), B (your wager), C (your opponents wager) and D (your opponent's pile). You put up 3 and your opponent puts up 1 in your strategy:
Your System _ Simple Case _ Flip
A B C D _____ A B C D _____
7 3 1 9 ___.__ 9 1 1 9 _____ Start
7 4 1 8 ___.__10 1 1 8 __.__ H
7 5 1 7 ___.__11 1 1 7 __.__ H
7 6 1 6 ___.__12 1 1 6 __.__ H
7 5 1 7 ___.__11 1 1 7 __.__ T
7 4 1 8 ___.__10 1 1 8 __.__ T
7 3 1 9 ______ 9 1 1 9 __.__ T
7 2 1 10 _____ 8 1 1 10 __._ T
7 1 1 11 _____ 7 1 1 11 __._ T
4 3 1 12 _____ 6 1 1 12 __._ T
4 4 1 11 _____ 7 1 1 11 __._ H
4 5 1 10 _____ 8 1 1 10 __._ H
4 6 1 9 ____._10 1 1 9 ___._ H
8 3 1 8 ____._11 1 1 8 ___._ H
8 4 1 7 ____._12 1 1 7 ___._ H
8 3 1 8 ____._11 1 1 8 ___._ T
8 2 1 9 ____._10 1 1 9 ___._ T
8 1 1 10 _____ 9 1 1 10 __._ T
5 3 1 11 _____ 8 1 1 11 __._ T
Compare column C & D on the left with column C & D on the right. They're exactly the same no matter how the game goes! That means using your strategy instead of the simple strategy has ABSOLUTELY NO EFFECT ON YOUR OPPONENT'S AMOUNT AT ALL! The fact that you consider additional coins "in play" at any given time does not affect the outcomes in the slightest.
Why the deviation instead of usually only being up or down a few pennies in the trial runs then? The deviations from tending to break even in the long run are caused by the stop conditions. By specifying that rounds end "when I'm up by 5000 or down by 3 compared to recent levels" introduces an instability that if you've had a recent run of good luck you'll have won a few rounds recently and be up some 30k or more. If you've had a recent run of bad luck you may end up down the same amount. You could get similar results by having each player wager 5000 beans at a time.
In the end, it won't earn you Randi's million. In fact, given its performance in simulations, I'd say it isn't even worth a hill of beans :D
ETA: Avoiding the wrath of Bob the angry flower.
Bindamel
19th September 2006, 01:14 PM
Please address the following facts about my program:
When I run 5 pennies and try to go after either 1, 2, 3, 4, or 5 at a time here are the probabilities of winning:
5:1 83.5%
5:2 71.6%
5:3 62.6%
5:4 56.1%
5:5 50%
But if I were to just go after one penny at a time with a pile of 5 every time here are the probabilities:
5:1 X 5:1 = 69%
5:1 X 5:1 X 5:1 = 58%
5:1 X 5:1 X 5:1 X 5:1 = 48%
5:1 X 5:1 X 5:1 X 5:1 X 5:1 = 40%
Now Which game has better luck?
This is a “Where is the extra penny question.”
5:2 71.6%
That is correct, and can be split into two elements:
5:1, at 83.3%, and 6:1, at 85.7%
(Why, you ask? In order to win both pennies, you have to win one penny. Once you’ve won one penny, you have an extra penny to work with, which improves your odds of winning overall, as you’ve noted earlier in the thread.)
So, with 0.833 x 0.857 = 0.714, we still have our expected, balanced outcome; i.e there is a 71% chance of gaining 2, with a 29% chance of losing 5
0.71 x 2 – 0.29 x 5 = 0, so we’re still zero sum.
Your second example:
5:1 X 5:1 = 69%
is not the same, because you’ve secretly pocketed a penny in between the two games!
If you win the first round, you now have six pennies, but you’re only wagering 5 in round two, leaving one in your pocket. If you win the second round, you will have your seven, and you will get it 69% (83% x 83%) of the time. If you lose the second round, which will happen 14% (83% x 17%) of the time, you will still have the penny you pocketed after the first round, even though you’ve lost your original 5 pennies. Now we have three outcomes:
17% lose (2nd round doesn’t happen), -5 pennies
83 x 17 win, then lose, -4 pennies
83 x 83 win twice, +2 pennies
=0.17*-5+0.14*-4+0.69*2 = 0!
Make any sense, Corey?
nathan
19th September 2006, 01:18 PM
I changed to a seed of 8956
Seeding the random number generator with the same value on each execution will cause the same sequence of random numbers to be generated on a particular system. The system will intialize the seed with some system specific value IIRC. If the program is compiled on a different system you may not see the same random number sequence. Just letting y'all know.
The common way of initializing the random number generator randomly is to find a local source of entropy. clock is a good source
seed ((long)clock (NULL))
oh, and historically rand is not a very good random number generator. The low order bits are particularly bad. (I don't think the low order bit problem affects this program, because of the way it scales the random sequence.)
petre
19th September 2006, 04:04 PM
Darn on the lack of possible duplication, at least for others. I can provide the output files generated, though the one for the 100 million games is about 120 MB of text :)
Also, in my own version of the program, perhaps I'll just switch on the high bit and save a bunch of cycles. Should I ever find need to run it again.
It seems less useful now though, having demonstrated that as long as the opponent continues to use the same strategy (betting one coin each time, replacing it when lost and pocketing one when won), nothing else matters, the results remain the same no matter what strategy player 1 uses.
T'ai Chi
19th September 2006, 05:18 PM
Could someone post a graph of player 1's winnings for something very large like 100,000 trials?
My calculator starts choking on about 2000 trials.
HappyCat
19th September 2006, 07:18 PM
Could someone post a graph of player 1's winnings for something very large like 100,000 trials?
My calculator starts choking on about 2000 trials.
Here is 1,000,000 trials
http://img471.imageshack.us/img471/7716/graph2yx6.jpg
CoreyWhite
19th September 2006, 07:28 PM
Where's my millions?
William Smith
19th September 2006, 07:33 PM
Where's my millions?
In your head.
digithead
20th September 2006, 12:17 AM
HappyCat,
Again, why doesn't the game end when player A's bank goes to zero?
Can you run your program with this condition? If so, what's the average number of rounds before player A goes bankrupt?
Also, try running your program with 5000 pennies for player A, and 10 million pennies for Randi. What's the average number of rounds before player A goes bankrupt?
Thanks ahead of time...
-digithead
petre
20th September 2006, 08:22 AM
Where's my millions?
What's your paranormal claim? (the last one having been demonstrated non-existant)
Where's your application?
Where's your three affidavits?
When's your preliminary test?
When's your final test?
drkitten
20th September 2006, 08:40 AM
Again, why doesn't the game end when player A's bank goes to zero?
I believe that zero in this formulation represents, not player A's bank, but player A's winnings. I.e. when the value is zero, player A has broken even (as he has at the beginning of the game).
You would need to establish a parameter; i.e. player A goes bankrupt when his "winnings" reach negative five thousand, or negative ten thousand, or negative fifteen million, or whatever.
If you look at the chart, it's obviously a random walk, so the various Drunkard's Walk theorems apply.
IXP
20th September 2006, 10:04 AM
Hey dr,
You should apply. I think it is a paranormal ablility to look at chart and decide that it's a random walk.
IXP
drkitten
20th September 2006, 11:20 AM
I think it is a paranormal ablility to look at chart and decide that it's a random walk.
Well, I'm flattered.
But I disagree. No more than it's a paranormal ability for a doctor to look at an X-ray and decide it's tuberculosis as opposed to bad focus.....
digithead
20th September 2006, 11:28 AM
I believe that zero in this formulation represents, not player A's bank, but player A's winnings. I.e. when the value is zero, player A has broken even (as he has at the beginning of the game).
You would need to establish a parameter; i.e. player A goes bankrupt when his "winnings" reach negative five thousand, or negative ten thousand, or negative fifteen million, or whatever.
If you look at the chart, it's obviously a random walk, so the various Drunkard's Walk theorems apply.
Any definition of bankruptcy would do, however in most textbooks that I've seen this problem, bankruptcy is when a player's assets go to zero. It makes the math easier...
Also, doesn't CW want to bet his $50 against Randi's $1 million, winner take all? In this case, 0 is the bankruptcy point for either player...
And you are quite right about the random walk but I'm interested in the average time it takes for player A to go bankrupt. It might show this pseudomathematician his logical fallacy...
IXP
20th September 2006, 12:53 PM
Well, I'm flattered.
But I disagree. No more than it's a paranormal ability for a doctor to look at an X-ray and decide it's tuberculosis as opposed to bad focus.....
I think I could come up with some charts that look like a random walk, but are not. The best you can really do is give a probability that it was generated by a random walk.
IXP
William Smith
20th September 2006, 11:56 PM
I still do not see the "paranormal" aspect of this.
drkitten
21st September 2006, 08:56 AM
I think I could come up with some charts that look like a random walk, but are not. The best you can really do is give a probability that it was generated by a random walk.
You could also come up with photoshopped tubercular X-rays, too.
I stand by my statement.
CoreyWhite
23rd September 2006, 11:59 AM
/*
It is possible to use martingale probability theory to beat some games of chance. In a fair game of coin toss, where the odds
reach an equilibrium of 50/50 chain reactions do occur. This can be explained using martingale probability theory, but in
simpler terms it only shows an example of how order emerges out of chaos.
Example: One player has 3 pennies, and another player has only 1 penny. A fair coin is tossed every round to determine if a
penny is won or lost for either player. The odds are 3/4 that player A (Who begins with 3 pennies) will win the game. This is
entirely different than the martingale betting strategy, because only 1 penny is bet for each round of the game.
Because there are 3 ways player A may win, and only one way player B can win, player A has a concrete advantage. Player B,
only wins in the event that the coin is tossed in his favor 3 times in a row, while player A can win on the first throw. Or
he can win after losing the first coin toss, or he can win after losing the second coin toss. So the odds are 75% that he (or
she) will win in this game.
Upon further analysis it is possible to calculate the average number of coin flips before player A is likely to win. The
equation k(n-k) works for perfectly fair games according to martingale probability theory to solve this problem. In this case
3(4-3) solves the problem, so on average it takes 3 coin flips for player A to win.
To show that chain reactions occur you only have to move from the probability of winning the first game, and multiply it by
the probabilities of winning the following games. For example, if 3 pennies are used to play this game in an attempt to win
one penny, the odds are 3/4. And once that penny is collected there is now a 4/5th chance of winning another penny.
So statistics tells us that there is a (3/4) * (4/5) * (5/6) * (7/8) * (8/9) * (9/10) = 30% chance of the 3 pennies growing
into a pile of 10.
But in repeatable tests you will find that on average there is not a net win or loss in this game. If there is a 75% chance
of winning 1 penny, and a 25% chance of losing 3. The two odds cancel each other out, to create an equilibrium in 50/50
games.
And at the same time we can see that despite the fact that the initial value of coins reaches an equilibrium when the pattern
is extended to any length, we can show a concrete advantage to beginning with 3 pennies, instead of beginning with one.
In the last example player A had a 30% chance of winning 7 pennies, and totaling 10 in all. If we started with only one penny
then player A would just have to total 8 pennies in order to earn 7. So lets look at the math:
(1/2) * (2/3) * (3/4) * (4/5) * (5/6) * (6/7) * (7/8) = 12.5%
So we can cleary see that even though winning 7 pennies has the same expected value as losing 1 penny. Outside of repeatable
tests the odds of earning 7 pennies is clearly higher if you begin with 3.
I can also explain the laws of nature with these prinicples. If we look at the equation for gravity on earth, which
accelerates at 9.8 m/s we can derive an acceptable answer from the earlier equations. The gravity equation I am using is
sqrt(2*n/9.8).
In this example we are dropping a ball from 4.9 meters, and you can see it takes one second to land.
t = sqrt( ( 2(4.9 m) ) / ( 9.8 m/s^2 ) ) = 1 s
So here is my gravity theory. We are using the quadratic formula to
solve: 2*n/9.8 = k(n-k) , for k. (The formula k(n-k) finds the average number of coin flips).
k=(1/14) (7n +- sqrt(49 n^2 - 40 n)).
So now an example...
We are dropping a ball from 10 meters above the ground. So we plug 10
meters into n to solve for k.
k=(1/14) (7n +- sqrt(49 n^2 - 40 n))
k=9.791574237
My question to calculate the average number of coin flips in my game is
k(n-k), so we plug in k & n:
k*(10-k) = 2.040816327 = average number of coin flips
Now we take the square root of the average number of flips to get the
actual time it takes to land:
sqrt(avg flips) = 1.428571429 = number of seconds to land.
Now finally to factor in a problem with my equation we say that if k is 9.791574327, that means our large gravity pile is
that many pennies. And our small gravity pile is exactly 0.208425673 pennies!
Now for the source code. You can actually prove everything I have written by running a few simple test cases. In the
program when you set the initial beans to 5, and set 1, 2, 3, 4, or 5 beans as your goal, the output should look like this:
5:1 = 83.5%
5:2 = 71.6%
5:3 = 62.6%
5:4 = 56.1%
5:5 = 50%
But if you only play with 5 beans every time and only go after 1 bean with those 5 each game, then your output will look like
this;
5:1 = 83.5%
5:1 X 5:1 = 69%
5:1 X 5:1 X 5:1 = 58%
5:1 X 5:1 X 5:1 X 5:1 = 48%
5:1 X 5:1 X 5:1 X 5:1 X 5:1 = 40%
So there is all the proof you need. Which experiment would you rather play?
In my experiments even when the program runs 10,000,000, and starting with 3 beans, with a target of 5000. You will win 5000
beans 273 times, for winnings of 1,365,000 beans in total. And you would lose 3 beans 443323 times for a loss of 1,329,969
beans. So you ended up 35,031 beans ahead.
Try changing the seed and you will still be ahead in the long run.
Even if you play 100 million games you will still be ahead.
*/
#include <stdio.h>
#include <stdlib.h>
main ()
{
double r;
long int M;
double x;
int y;
int z;
int count;
int seed = 10000;
printf("Enter seend for RNG: ");
scanf("%d", &seed);
srand (seed);
M = 2;
int score = 0;
//Score keeps track of the number of beans won every game
int games = 0;
// games keeps track of the number of games we have played before
//losing all of the beans, which is equal to score.
int beans1 = 0;
// Initial value set to zero and defined within the loop
int wins = 0;
int lost = 0;
int quit = 0;
int init = 0;
int rounds = 0;
int live = 0;
printf ("Initial Beans: ");
scanf ("%d", &init);
printf ("Stop after winning X number of beans: ");
scanf ("%d", &quit);
scanf("%d", &rounds);
printf("Show live output (1 or 0): ");
scanf("%d", &live);
for (int cnt = 0; cnt < rounds; cnt++)
{
// We play up to (int) rounds
int count = 0;
beans1 = init + score;
// Beans gets defined here, as starting with 3 beans
// and having a 0 bonus score (It changes as you
// win more beans per round)
int beans2 = 1;
// The program attempts to win just one
// bean for every game.
while (beans1 != 0 && beans2 != 0)
// The battle begins
{
r = ((double) rand () / ((double) (RAND_MAX) + (double) (1)));
x = (r * M);
y = (int) x;
z = y + 1;
// A coin is flipped and is either 1 or 2 in value
if (z == 1)
{
// Heads wins.
beans1++;
// Beans1 gains one bean from Beans2
beans2--;
}
if (z == 2)
{
// Tails loses
beans1--;
// Beans2 gains one bean from Beans1
beans2++;
}
count++;
// We keep track of the number of rounds in the battle
}
if (beans1 > score + init)
{
// If beans1 is greater than the initial value
// of beans plus the total number of beans
// that have been won so far in this game, then
// the score goes up, and we go on to the next
// game. We check this at the end of every game.
score++;
games++;
}
if (beans1 <= 0)
{
//If beans1 has lost the game and doesn't
//have anymore beans then we know the
//game is over, so we reset score, and reset
//games.
if(live==1){
printf ("Lost at: %d beans , %d games.\n", score + init, games);
}
// And we print out the total number of
// games played on this trial and show the
// total score plus the initial value of beans.
lost++;
score = 0;
games = 0;
}
if (score >= quit)
{
wins++;.
if(live==1){
printf ("Won at: %d beans , %d games.\n", score + init, games);
}
beans1 == 0;
score = 0;
games = 0;
}
}
printf ("Total Won: %d/%d\n", wins, wins + lost);
printf ("Net win: %d beans.\n",(wins*quit)-( (wins+lost)*init ) );
}
webfusion
23rd September 2006, 12:22 PM
That last post contains gibberish.
CoreyWhite
23rd September 2006, 12:58 PM
No, its just badly formatted. Her it is again with some minor alterations and improvements.
#include <stdio.h>
#include <stdlib.h>
main ()
{
double r;
long int M;
double x;
int y;
int z;
int count;
int seed = 10000;
printf("Enter seend for RNG: ");
scanf("%d", &seed);
srand (seed);
M = 2;
int score = 0;
//Score keeps track of the number of beans won every game
int games = 0;
// games keeps track of the number of games we have played before
//losing all of the beans, which is equal to score.
int beans1 = 0;
// Initial value set to zero and defined within the loop
int wins = 0;
int lost = 0;
int quit = 0;
int init = 0;
int rounds = 0;
int live = 0;
printf ("Initial Beans: ");
scanf ("%d", &init);
printf ("Stop after winning X number of beans: ");
scanf ("%d", &quit);
printf ("Number of rounds: ");
scanf("%d", &rounds);
printf("Show live output (1 or 0): ");
scanf("%d", &live);
for (int cnt = 0; cnt < rounds; cnt++)
{
// We play up to (int) rounds
int count = 0;
beans1 = init + score;
// Beans gets defined here, as starting with 3 beans
// and having a 0 bonus score (It changes as you
// win more beans per round)
int beans2 = 1;
// The program attempts to win just one
// bean for every game.
while (beans1 != 0 && beans2 != 0)
// The battle begins
{
r = ((double) rand () / ((double) (RAND_MAX) + (double) (1)));
x = (r * M);
y = (int) x;
z = y + 1;
// A coin is flipped and is either 1 or 2 in value
if (z == 1)
{
// Heads wins.
beans1++;
// Beans1 gains one bean from Beans2
beans2--;
}
if (z == 2)
{
// Tails loses
beans1--;
// Beans2 gains one bean from Beans1
beans2++;
}
count++;
// We keep track of the number of rounds in the battle
}
if (beans1 > score + init)
{
// If beans1 is greater than the initial value
// of beans plus the total number of beans
// that have been won so far in this game, then
// the score goes up, and we go on to the next
// game. We check this at the end of every game.
score++;
games++;
}
if (beans1 <= 0)
{
//If beans1 has lost the game and doesn't
//have anymore beans then we know the
//game is over, so we reset score, and reset
//games.
if(live==1){
printf ("Lost at: %d beans , %d games.\n", score + init, games);
}
// And we print out the total number of
// games played on this trial and show the
// total score plus the initial value of beans.
lost++;
score = 0;
games = 0;
}
if (score >= quit)
{
wins++;.
if(live==1){
printf ("Won at: %d beans , %d games.\n", score + init, games);
}
beans1 == 0;
score = 0;
games = 0;
}
}
printf ("Total Won: %d/%d\n", wins, wins + lost);
printf ("Net win: %d beans.\n",(wins*quit)-( (wins+lost)*init ) );
}
kittykatkarma
23rd September 2006, 01:26 PM
You need to take your medication Tobias, and it wouldn't hurt learning to play the piano either. For an autistic kid you should know that the computer isn't going to get you anywhere in life. It is just a forum, k?
Corey ~
This line of crap is never necessary or appropriate. You need to step back and examine your manners and don't be rude to anyone in this manner again.
You may always speak your point of view, but you may never personally attack anyone.
I concur with Tobias, "you are a bad person". I will add that you are as such because you are selfish, and have no regard for others.
Admiral
23rd September 2006, 01:43 PM
Well, he's banned now. I don't think anyone will miss him.
kittykatkarma
23rd September 2006, 01:53 PM
Well, he's banned now. I don't think anyone will miss him.
Must have just gotten himself banned... last posted at 2:27PM... or so.
William Smith
23rd September 2006, 11:39 PM
Well, he's banned now. I don't think anyone will miss him.
Quelle surprise.
T'ai Chi
24th September 2006, 10:52 AM
Thanks for the post of 1,000,000 trials.
Can anyone post one for 10,000,000 trials?
© 2001-2009, James Randi Educational Foundation. All Rights Reserved.
vBulletin® v3.7.7, Copyright ©2000-2012, Jelsoft Enterprises Ltd.