Thursday, February 26, 2015

I played 800 games of 100 coin toss

You have to read this article before this to make sense of what I'm saying here.


After putting up the probability distribution and showing that after playing 100 toss of coin, where each head gives you $2 and each tail takes away $1 from you, will not always give you a positive returns, I was still unsatisfied.


I went ahead and did a monte carlo simulation of the game on excel. Using RAND() function, I will get a random value between 0 and 1. I programmed it such that if I have a number bigger or equal to 0.5, it'll be heads and I'll assign a value of 1 to it. If not, it'll be tails and I'll assign a value of 0 to it.

IF( cell >= 0.5, 1, 0) 

After tallying the number of heads and tails, I proceed to count the gain/loss from this 100 toss game. I did 800 simulation of such 100 coin toss, effectively throwing 80,000 coins in my computer program.


HUAT AH!

Here's the results of all 800 such games of 100 coin tosses. The numbers in each cell represents the gain/loss from playing the game:



I highlighted 2 cells in yellow because this is what I get after playing 800 such games - I've two games where I have negative returns! The probability is higher than the initial theoretical calculation. The theoretical probability of ending up having losses after 100 coin tosses is 0.043686%. Based on this monte carlo simulation, I have 2/800 or 0.25% of ending up not being profitable.


I calculated the average score of all these 800 games of 100 coin tosses, and it turns out to be $49.43875, which is very close to the expected value calculated of $50. Just for interest sake, the mode (the sum that occurred most often) of all 800 such games is $53 and the median is $50.


There! The statement that after 100 coin tosses, you always end up being profitable is not true. Combining the new found skills in excel simulation with real life examples is really really interesting LOL

18 comments :

Singapore Man of Leisure said...

LP,

You har!

But then, you have illuminated why so many PhDs at Long Term Capital failed so badly...

I am sure some readers looking at your simulation may say:

"Win 798 times and lose 2 times - what's the problem?"

Well, the problem is when you go ALL-IN with massive leverage (after winning consecutive 798 times who is not complacent?) and you hit one of these 2 times...

Just like some Fx brokerages that went broke after the quite "improbable" event in Switzerland breaking the EUR/CHF floor of 120.

hydrogenperoxide said...

To simplify.. Can use randbetween 0 and 1 and set it directly.. Lol hahaha.. I love to poke fun.. Hahahaha

S-Reit System Investor said...

Hello LP,

The lesson I learn here is never to be absolute in my statements. But it's amazing how you go all out to prove a point. LOL

la papillion said...

Hi SMOL,

You get the point why I'm doing this :) I am never into probability and am never assured by this illusion of certainty. The moment someone say no risk, it'll be a different perception from having low risk. The jump between 2% to 1% is not the same as the jump between 1% to 0%!!

la papillion said...

Hi h202,

Can explain what you mean? I would love a shortcut to program it :)

la papillion said...

Hi srsi,

Haha! I'm not confrontational - I'm just having fun! The point of doing this is to convince myself and to learn at the same time. I recently studying a module where I have to simulate business models, so I'm just applying what I'm learning :)

This is a scientific and mathematical poke lol!

RetailTrader said...

CNY everyone in gambling mood? ;)

Anonymous said...

Pardon for my ignorance, how do you end up with two -ve outcomes since the assigned value is 0 for tail and 1 for head.

la papillion said...

Hi RT,

Haha ;) Throw coins only, huat ah!

la papillion said...

Hi anon,

Pls do leave your nickname? Thanks!

You should read the previous article to see how I get the returns. Anyway, the game is such that for every heads you get, you get $2. Every tails you get, you'll lose $1. So if you throw 100 coins, and you hve 25 heads for example, you'll have 25 x $2 - 75 x $1 = -$25. The 800 values you see on the chart with the 2 yellow cells are the returns you get, not the number of heads. If you see a value of 55, it means you get $55 in return.

So it's possible to get -ve values.

abcde said...

Hi, I'm curious as to which formulas you used to get the 800 x 100 throws in the excel sheet. Do you mind specifying exactly what formula you put in each cell and to get 100 throws for each cell? Just trying to improve my knowledge in excel, thanks! :)

la papillion said...

Hi abcde,

I got 100 throws first, with 1 representing heads and 0 representing tails. Then I did a formula to see how many heads I get, after which I did $2 x (no of heads) - 1 x (100 - no of heads) to get the returns in each 100 throw game.

Then I literally type out 800 values. There's an easier way to do this, I think, but I want to see it visually in a matrix form.

I attach my excel spreadsheet for your perusal : https://www.dropbox.com/s/d5u6kqr836tyayz/monte%20carlo.xlsx?dl=0

Turtle Investor said...

Just wanted to applaud your efforts! Thankfully there is Excel or you wld be tossing coins the whole night =)

la papillion said...

Hi Turtle investor,

Hahaha! I will toss until my hands go numb haha :)

This is my first monte carlo simulation...will do more next time ;)

Createwealth8888 said...

There is no risk free investment. All investment by nature is risky and we may lose our capital.

But, we can still try to achieve zero capital at risk investing and don't lose our capital. Good enough?

:-)

Sillyinvestor said...

LP,

Actually, I see it from a different perspective.

Your experiment prove that it is Indeed mathematical sound, the 2 negative returns is -1, but the positive returns varies, and it is 2 out of 800.

Mathematical sound does not mean it is flawless or Bao Jia thou...

Like what SMOL say, u all in and use leverage, it's a temperament and mind problem, not a method problem.

The method is sound, the mind is not, mind and method cannot be at logger heads.

If in real fact, if traders can find such high rate of success and have the discipline for stop loss, I think he is super successful.

But the odds of win 2 lose 1 in itself is abitary. It is possible to win 10 lose 1, but the probability of win 10 lose 1 will not be 50-50.

la papillion said...

Hi bro8888,

I understand your pillow strategy :) but some may argue that your capital is still your hard earned profit and it is still at risk Haha!

la papillion said...

Hi SI,

Hmm? I don't get why your perspective is different? Isn't it the same?

Of cos in real life the probability will not be 50-50. A 50-50 game of chance with $2 win and $1 loss combined with strict cut loss is as good as it gets. This is a game that has odds in your favour!

I'm not disputing the article Btw. I thought the article makes a lot of sense. I'm just disputing that word 'always' when it said after playing 100 tosses, you'll always be profitable. Not true.