Sunday, September 18, 2016

Economic Data of World's Major Economies

Unlike other posts of mine, this one is just a list of Mini Dashboard & Charts of Economic Data of major world economies. The first one is the Mini Dashboard, you can access it here.

Charts are created using the Visualisation Application http://www.StatsPanda.com

Before you scroll down, here are the steps I followed for creating the charts.

1. Uploaded the spreadsheet with economic data to StatsPanda.com.
2. Created a Datasource with the Data from the uploaded spreadsheet.
3. Used the same Datasource to create the following charts & the mini dashboard.

You need to be a logged in user in StatsPanda.com and your profile registration must be completed before you try out the above steps. For details, you may refer to their blogs @ http://blog.statspanda.com

Major World Economies Export, Import, GDP (in ppp terms), Debt in $ billions:



Data related to Top World Economies:




GDP (PPP & Nominal) and Debt of the countries along Export & Import:




Export (Y-Axis) vs Import (X-Axis) vs Size of Economies (GDP in PPP terms) for top World economies:




Hope you find it useful.

Saturday, August 20, 2016

Stupid! You never Gonna Make Money in Gamble.

Recently I bought two dices thinking I will use them to play with my three and half year old daughter and that may help enhance her maths skills. Unfortunately, she lost interest in the dices in first 10 minutes but they made me curious enough to spend few more days with the dices and then finally to write a java program that can simulate the game of rolling two dices for millions of times at my wish.

A simple game will involve rolling two dices and add the numbers appearing on the sides facing upwards to determine winning bet (number). The person who betted on that number is the winner. Every dice has 6 faces with numbers 1 through 6. So, sum of the numbers from two dices will be one of these 11 numbers - 2, 3, 4, 5, 6 , 7, 8, 9, 10, 11, 12. Interestingly, some of the numbers from the list have higher chances of appearing than others, simply because they can be produced by more combinations. For example, 2 can be produced only by 1 + 1 but 7 can be produced by 1 + 6, 2 + 5, 3 + 4, 4 + 3 and more. That makes 7 a far more lucrative an option for a gambler to pick when compared to 2. Overall there are 6 x 6 = 36 different ways you can get one of 11 numbers.

Let's go ahead and spend some time looking into the data that the Java program generated and how gambling may use this variability in probability distribution to give rich people an adrenaline rush. This program simulates rolling of two dices by generating two random numbers in the range  of 1 - 6. Then is sums them up to come up with the winning number. It repeats the steps as many times as you ask it to.

Let's generate the frequency distribution by rolling of two dices for 10 million times. 


| Position  | Frequency | Feq in % | 
------------------------------------------
| Number 12 | 277,771 | 2.78% | 
------------------------------------------
| Number 2 | 277,148 | 2.77% | 
------------------------------------------
| Number 4 | 831,981 | 8.32% | 
------------------------------------------
| Number 3 | 555,619 | 5.56% | 
------------------------------------------
| Number 6 | 1,389,822 | 13.9% | 
------------------------------------------
| Number 5 | 1,110,738 | 11.11% | 
------------------------------------------
| Number 8 | 1,389,151 | 13.89% | 
------------------------------------------
| Number 7 | 1,666,267 | 16.66% | 
------------------------------------------
| Number 9 | 1,112,411 | 11.12% | 
------------------------------------------
| Number 11 | 555,447 | 5.55% | 
------------------------------------------
| Number 10 | 833,645 | 8.34% | 
------------------------------------------
| Total Rounds | 10,000,000 | 100% | 
------------------------------------------

This distribution is similar to what you will see if you do a simple calculation using permutation formula. Although, I personally never found permutation & combination simple.

Now, let's make it a little serious affair. To have a real gamble, we will bring in real money and a Table Owner who runs the Games of Gamble. Table owner takes certain % cut and rest of the money goes to the winning bet.
  
The games will be played by 11 Players. Each player can bet only on one specific number and can bet for $10. Table owner will charge 20% of the amount betted. The games will be played for 2 million times. So, total money involved is $220 million.

| Player Position  | Money Earned | % of Total Bet Amount |
---------------------------------------------
| Player 10 | $14,669,600 | 7% | 
---------------------------------------------
| Player 11 | $9,750,488 | 4% | 
---------------------------------------------
| Player 8 | $24,552,264 | 11% | +ve
---------------------------------------------
| Player 7 | $29,277,952 | 13% | +ve
---------------------------------------------
| Player 9 | $19,553,160 | 9% | 
---------------------------------------------
| Player 4 | $14,633,696 | 7% | 
---------------------------------------------
| Player 3 | $9,773,192 | 4% | 
---------------------------------------------
| Player 6 | $24,457,400 | 11% | +ve
---------------------------------------------
| Player 5 | $19,573,752 | 9% | 
---------------------------------------------
| Player 2 | $4,876,344 | 2% | 
---------------------------------------------
| Player 12 | $4,882,152 | 2% | 
---------------------------------------------
| Table Owner | $44,000,000 | 20% | 
---------------------------------------------
| Spend Per Player | $20,000,000 | 9% | 
---------------------------------------------
| Total Amount Betted | $220,000,000 | 100% | 
---------------------------------------------

As you can see Table Owner gains the most. With exception of him, there are only three other players - Player 7, Player 6 & Player 8 who made some money and there are 8 other players who lost money. 

But we know it was not practical. How can you expect a Gambler to try his luck only with one number? Let's take out that restriction along with few other restrictions - number of players could be anything between 1 to 11, players can bet any amount ranging from $10 to $1000 on any number and Table Owner will not have any pre-defined cut. However, we will still not allow more than one bet to be placed against one number. Number of players and the amount they bet in one particular round will be randomly determined by the program. The game will continue for 1 million times.


TOTAL AMOUNT BETTED BY EACH PLAYER POSITION
------------------------------------
Player Position 4 | $276,025,231
------------------------------------
Player Position 5 | $275,850,639
------------------------------------
Player Position 6 | $275,374,362
------------------------------------
Player Position 7 | $275,526,040
------------------------------------
Player Position 2 | $275,613,052
------------------------------------
Player Position 3 | $274,947,829
------------------------------------
Player Position 10 | $275,777,883
------------------------------------
Player Position 11 | $275,233,244
------------------------------------
Player Position 12 | $275,308,337
------------------------------------
Player Position 8 | $275,197,852
------------------------------------
Player Position 9 | $274,973,749
------------------------------------
Total Betted Amount | $3,029,828,218
------------------------------------

TOTAL AMOUNT WON BY EACH PLAYER POSITION 
-----------------------------------------------
| Player Position 4 | $175,887,913 | 5.81% | 
-----------------------------------------------
| Player Position 5 | $234,566,644 | 7.74% | 
-----------------------------------------------
| Player Position 6 | $292,437,606 | 9.65% | +ve
----------------------------------------------- 
| Player Position 7 | $350,616,777 | 11.57% | +ve
-----------------------------------------------
| Player Position 2 | $57,980,399 | 1.91% |
-----------------------------------------------
| Player Position 3 | $118,038,318 | 3.90% |
-----------------------------------------------
| Player Position 10 | $176,005,502 | 5.81% |
-----------------------------------------------
| Player Position 11 | $117,401,400 | 3.87% |
-----------------------------------------------
| Player Position 12 | $58,484,553 | 1.93% |
-----------------------------------------------
| Player Position 8 | $294,861,804 | 9.73% |
-----------------------------------------------
| Player Position 9 | $233,939,146 | 7.72% | +ve
-----------------------------------------------
| Table Owner | $919,608,156 | 30.35%
-----------------------------------------------
| Total Amount Betted | $3,029,828,218 | 100.00%
-----------------------------------------------

Take a look, in this case we had no pre-determined cut for the Table Owner but he still made a billion ;). As for the playing positions, same trend continues i.e. Playing Position 6, 7, 8 gave positive returns and rest all numbers lost money. If that's the case why would any one put money on any other number? They won't put money anywhere other than 7. Obviously, this is not a fair game.

So, lets design a Fair Game. Goal would be to neutralise the effect of position by giving differential returns.  

Here are two tables showing how much will be your return for every $ you bet on each of the positions if yours is the winning bet:


Table Owner doesn't charge anything
----------------------
| Number 12 | $36 |
----------------------
| Number 2 | $36 |
----------------------
| Number 4 | $12 |
----------------------
| Number 3 | $18 |
----------------------
| Number 6 | $7 |
----------------------
| Number 5 | $9 |
----------------------
| Number 8 | $7 |
----------------------
| Number 7 | $6 |
----------------------
| Number 9 | $9 |
----------------------
| Number 11 | $18 |
----------------------
| Number 10 | $12 |
----------------------

Table owner takes a cut of 20%.
----------------------
| Number 10 | $10 |
----------------------
| Number 11 | $15 |
----------------------
| Number 8 | $6 |
----------------------
| Number 7 | $5 |
----------------------
| Number 9 | $7 |
----------------------
| Number 4 | $10 |
----------------------
| Number 3 | $14 |
----------------------
| Number 6 | $6 |
----------------------
| Number 5 | $7 |
----------------------
| Number 12 | $29 |
----------------------
| Number 2 | $29 |
----------------------

Take a look at the above tables once again and you will realise the returns on the Winning number looks pretty good and at the same time it's fair. No number has any advantage over another number when it comes to overall return over sufficiently large number of games of gamble. At the same time it can accommodate the risk appetite of any gambler by giving differentiated returns, inversely proportional to the probability of a number coming up as a winning bet. Voila! we just designed a game of gamble which is probably closest to what you would see in a casino.

Let's check the returns for various numbers - 8, 7, 12 over 3 million bets for each of them when the Table Owner takes a 30% cut. Amount of each bet is $10. Returns are similar irrespective of probability of the number coming up.

Gambler betting on 7
 -----------------------------------------------
| Table Owner | $9,526,117 | 31.75%
-----------------------------------------------
| Player 7 | $20,473,883 | 68.25%
-----------------------------------------------
| Total Amount Betted | $30,000,000 | 100.00%
-----------------------------------------------

Gambler betting on 8
-----------------------------------------------
| Table Owner | $9,218,150 | 30.73%
-----------------------------------------------
| Player 8 | $20,781,850 | 69.27%
-----------------------------------------------
| Total Amount Betted | $30,000,000 | 100.00%
-----------------------------------------------

Gambler betting on 12
-----------------------------------------------
| Table Owner | $9,019,975 | 30.07%
-----------------------------------------------
| Player 12 | $20,980,025 | 69.93%
-----------------------------------------------
| Total Amount Betted | $30,000,000 | 100.00%
-----------------------------------------------

Next, I am going to try the same gamble i.e. Payoff Matrix is fair and Table Owner takes a cut, with rest of the factors are randomised. In the example below number of players ranges from 6 to 20, game continues for 10 to 100,000 times, betted amount ranges from $10 to $1000 and Table Owner takes a cut of 20%. Outcome is similar. On an average, all the players lose the amount that the Table Owner charges. 

No of Rounds 9973
No Of Players 18

TOTAL AMOUNT BETTED BY GAMBLERS 
-----------------------------------------
| Player 10 | $5,049,130 | 5.57%
-----------------------------------------
| Player 11 | $5,049,573 | 5.57%
-----------------------------------------
| Player 8 | $5,041,264 | 5.56%
-----------------------------------------
| Player 7 | $5,052,238 | 5.57%
-----------------------------------------
| Player 9 | $5,039,512 | 5.56%
-----------------------------------------
| Player 4 | $5,064,714 | 5.58%
-----------------------------------------
| Player 3 | $5,022,313 | 5.54%
-----------------------------------------
| Player 6 | $5,003,299 | 5.52%
-----------------------------------------
| Player 5 | $5,069,510 | 5.59%
-----------------------------------------
| Player 0 | $5,032,736 | 5.55%
-----------------------------------------
| Player 2 | $5,090,774 | 5.61%
-----------------------------------------
| Player 1 | $5,014,831 | 5.53%
-----------------------------------------
| Player 16 | $5,026,509 | 5.54%
-----------------------------------------
| Player 17 | $5,028,077 | 5.54%
-----------------------------------------
| Player 12 | $5,015,401 | 5.53%
-----------------------------------------
| Player 13 | $5,024,943 | 5.54%
-----------------------------------------
| Player 14 | $5,047,221 | 5.56%
-----------------------------------------
| Player 15 | $5,024,303 | 5.54%
-----------------------------------------
| Total Amount Betted | $90,696,348 | 100.00%
-----------------------------------------

Total Amount Won
--------------------------------------------
| Player 10 | $4,211,682 | 4.64%
--------------------------------------------
| Player 11 | $4,117,135 | 4.54%
--------------------------------------------
| Player 8 | $3,931,574 | 4.33%
--------------------------------------------
| Player 7 | $4,170,266 | 4.60%
--------------------------------------------
| Player 9 | $4,144,855 | 4.57%
--------------------------------------------
| Player 4 | $4,310,571 | 4.75%
--------------------------------------------
| Player 3 | $4,013,216 | 4.42%
--------------------------------------------
| Player 6 | $3,910,301 | 4.31%
--------------------------------------------
| Player 5 | $4,083,093 | 4.50%
--------------------------------------------
| Player 0 | $4,090,285 | 4.51%
--------------------------------------------
| Player 2 | $4,209,126 | 4.64%
--------------------------------------------
| Player 1 | $3,955,758 | 4.36%
--------------------------------------------
| Player 16 | $4,161,625 | 4.59%
--------------------------------------------
| Player 17 | $3,849,358 | 4.24%
--------------------------------------------
| Player 12 | $3,904,212 | 4.30%
--------------------------------------------
| Player 13 | $4,074,304 | 4.49%
--------------------------------------------
| Player 14 | $4,022,716 | 4.44%
--------------------------------------------
| Player 15 | $3,983,948 | 4.39%
--------------------------------------------
| Table Owner | $17,552,323 | 19.35%
--------------------------------------------
| Total Amount Won | $90,696,348 | 100.00%

--------------------------------------------

If you had generated the Payoff Matrix without paying anything to the Table Owner, the long term returns for the Gamblers would reflect the same i.e. amount betted and won would be almost the same. But that's not how real world works. Such patterns hold good only for sufficiently large amount games. For lesser number of games the results could be very unpredictable. Gamblers may make a killing or may lose significantly. In fact, the Table Owner may not make any money or may end up earning much more than the planned cut. 

Across all of the data shared above, one point becomes pretty obvious - that a gambler will never make money irrespective of where he puts his bet on. That's true even when he spends all his wealth and his lifetime playing a fair game of gamble. Gambling is meant for adrenaline rush & one pays for that service. That's it. No one is smart enough to make money in gambling over period of time, unless you run the Game of Gamble. 

Hope you enjoyed reading the post.