4 ms·
I 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 panda
by nonameiguess 6y ago
I 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]
- concreteblock 6y agoNo matter how many test subjects you use, if you run the experiment for a very long time, everyone goes bankrupt and will never recover. More precisely there is a finite time after which no-one ever passes above $0.0000000000000001. That is a mathematical theorem. This doesn’t depend on the number of test subjects, and you can add as many zeroes as you want. Therefore in the long run the mean outcome is 0. Forgive me if I have misinterpreted what you are are trying to say. Edit: I’ve just realized that I have indeed missed your point.
- kgwgk 6y agoNo matter for how long you run the experiment if you use enough subjects some of them will win an absurdly large amount of money and the sample mean will converge to the mean of the distribution (which grows exponentially with time). It’s a mathematical theorem. (I would be curious to see a proof of your theorem, by the way.)
- jackcosgrove 6y agoSo if you get lucky you de-risk and make small bets comparable to your initial winning bet, rather than betting it all. Sounds like a good strategy whether in Vegas or Wall Street.
- javitury 6y agoTry these parameters n_subjects = 1000 n_trials = 100