6 ms·
This is wrong and misses the point of the post. The median outcome is indeed negative, for the reason you give. But the mean outcome is positive, because some
by maximilianroos 6y ago
This is wrong and misses the point of the post.
The median outcome is indeed negative, for the reason you give. But the mean outcome is positive, because some players become exceedingly rich.
You can try it at home, here's some Julia which runs it over 1M people, each with 1K flips:
using Distributions
n = 1000
d = Binomial(n, 0.5)
to_wealth(heads) = 1.5^heads * 0.6^(n - heads)
rand(d, 1_000_000) .|> to_wealth |> mean
You can keep running that, it's above 1 almost all the time.
To look at this another way — would you take the other side of the bet? Someone on average has to be making money, and the other side is clearly losing money.
- nonameiguess 6y agoI did run this many times by adapting the OP's own code (and vectorizing it, which he asked someone to do). Here it is: import numpy as np import pandas as pd n_subjects = 100 n_trials = 1000 start = 10.0 win = 1.5 loss = 0.6 prob = 0.5 results = np.ones((n_trials, n_subjects)) * start for trial in range(1, n_trials): wins = np.random.binomial(1, prob, n_subjects) == 1 results[trial, wins] = results[trial - 1, wins] * win results[trial, ~wins] = results[trial - 1, ~wins] * loss ax = pd.DataFrame(results).plot(legend=False, figsize=(18,10), logy=True, linewidth=0.5) ax.plot(results.mean(axis=1), color='red', lw=2, linestyle='--') The mean always trends to 0 and every single player eventually loses. There are never any winners at all past around 500 trials or so. Not sure how you're getting a different result as I have never used Julia and can't tell what your code is doing (except apparently something different).
- pcmonk 6y agoI think your n_subjects is too low. You need that to be high enough or you'll miss those low-probability winners that bring up the average.
- nonameiguess 6y agoI did it with more subjects and it doesn't make a difference. The only reason I reduced to 100 is because the plot is unreadable otherwise. Looking at the Julia code, I think what he is doing wrong is making all wins worth $.50 and all losses worth $.40, but the bet computes a win or loss based on your current wealth, not your starting wealth. His formula would work if you were always betting $1 no matter what your bankroll was, but that isn't what the actual post stipulates.
- maximilianroos 6y agoYou're so fixed to your conclusion that you're now reading code wrong. If you don't trust the Julia code, try running with the same parameters in Python.
- nonameiguess 6y agoI don't understand why you think changing the number of participants changes the ensemble average. I just ran it with 1,000,000 participants and 1,000 trials and ended up with an ensemble average of $0.07 on the 1,000th trial, trending toward 0. The only difference is the simulation took longer. The curve looks exactly the same. The ensemble average trends upward until about 500 trials, then trends downward and keeps doing so forever. My code is right up there and you can run it. You can even just run the OP's notebook that he provided but increase the number of trials. Change the "num_flips_per_sim" parameter he provides in cell 6 to anything over 500 and you will always get sum(count_lose_capital) == everyone.
- maximilianroos 6y agoTake the outside view here — 3-4 people have commented, all disagreeing with you. One of them has offered an explanation of why you're experiment is poorly designed, and I've given you code which produces a different result. The appropriate response to that is introspection, not repetition.
- deleted 6y ago[deleted]
- javitury 6y agoTry these parameters n_subjects = 1000 n_trials = 100
- deleted 6y ago[deleted]
- simonebrunozzi 6y agoIsn't Julia amazing for these types of things?