Rendered at 02:42:20 GMT+0000 (Coordinated Universal Time) with Cloudflare Workers.
alexpotato 5 hours ago [-]
> After running 10 million simulated draws, I got an answer of 0.0323, which matches the real answer very closely.
If you enjoyed reading about how you can approximate complex statistical values using basic programming, I highly recommend Jake Vanderplas "Statistics for Hackers" [0][1].
It converts the sometimes hard to grok statistics terms and formulas into some very simple loops and basic operations.
I wrote a Monte-Carlo simulation while working on a Pokemon-Go style game to simulate people walking all over the world. I used statistics for average walking speed and times played for similar games. To my amazement when the game launched, my predictions were within +/- 2%! A career highlight.
theOGognf 5 hours ago [-]
Those interested in this should read about DSMC: https://en.wikipedia.org/wiki/Direct_simulation_Monte_Carlo. It’s the same idea for low density gas interactions without having to actually simulate all the particles involved while still getting accurate results. Cool stuff!
hingler36 5 hours ago [-]
There's been a lot of interesting work in the last ~decade on improving monte-carlo methods for solving PDEs, the field is really fascinating!
I (and Claude) have been working on an open source monte carlo based retirement tool for quite a while now. Its definitely geared towards people with more individual financial ownership and tech knowledge but I feel it gives good flexibility for me to model my situation. I had initially gravitated to this project because I think Monte Carlo and numerical methods are just so dang fun.
I was working on a retirement planning simulation this week with Opus and it added this simulation into my tool! Had never heard of Monte-Carlo before but was fairly impressed.
nxobject 2 hours ago [-]
As a statistician, I’d be remiss if I didn’t mention bootstrapping - theoretically distinct, but another demonstration of the power of randomization techniques.
stevenhubertron 4 hours ago [-]
I use a Monte-Carlo for my retirement planning. This did a good job of telling me not to trust it but didn't really give me a better option. Anyone have one?
Jtsummers 4 hours ago [-]
> This did a good job of telling me not to trust it
What do you mean? The retirement planning with Monte-Carlo gave a better result than the base assumption of 4% returns and 2% inflation. The information MC provides let's you, when taking into account your risk threshold, whether you're satisfied with your savings or not by giving you more realistic odds of how long the money will last.
sokoloff 2 hours ago [-]
I don’t think a pure Monte Carlo is as helpful as “replaying” past actual scenarios (or a hybrid of the two).
I don’t have reason to believe that 40 years in a row would all have randomly and independently chosen results from a distribution (pure Monte Carlo) as a better model than past actual results.
lastofus 3 hours ago [-]
There's no sure fire option for making sure you don't run out of money, as nothing can 100% predict the future. The best we have is the assumption that the future will look kinda like the past over long periods of time.
If you acknowledge that assumption, then you have to choose what model of the historical market you want to use a predictor for the future.
You can use exact market data, test retiring out at every single possible year at every possible asset allocation and see what happens. This is the basis of the 4% rule from Bill Bingham.
You can pull random years out of history and string them together a bunch of times and see what happens with a given asset allocation. This is a naive Monte Carlo simulation.
You can pull blocks of years and string them together, to acknowledge that there are repeating trends in years (what happens in one years influences the next) and do a Monte Carlo simulation which is a bit less naive.
There are more esoteric models overly smart people have constructed, each of which will give you slightly different answers for a safe withdraw rate.
At the end of the day though we are all just crossing our fingers, and hoping for a black swan catastrophe to not happen.
charlieyu1 4 hours ago [-]
If you are doing combinatorial sampling like estimating pi or doing probabilities with SET, stratification is a great idea
shoo 3 hours ago [-]
Here's a few related ideas:
1) rejection sampling - this is the name to the general technique used in the first example, to estimate pi by sampling from a uniform distribution over a unit square (easy) and then rejecting the samples that fall outside of the distribution you're actually interested in (unit disk).
Another simple example of rejection sampling is if you want to randomly pick between 5 ordered options and only have a d6. Roll the d6. If you roll a 6, reject the roll & re-roll. If you roll 1-5, that's your choice.
2) the Metropolis-Hastings algorithm -- this is a Markov chain Monte Carlo algorithm. It can be useful in some applications to sample from a distribution that is difficult to sample from.
Suppose you have some system described by a state vector x & you know that the probability of the system being in state x, p(x), is proportional to q(x), where q is some function you can compute. If you could integrate q over x, to give Z := integral_{x in X} q(x) dx then you'd have p(x) = Z^-1 q(x)
For a concrete example, x might be a state vector of a physical system -- say a bunch of molecules in a box, where you can compute the energy of any given state u(x) and know the probability of x, p(x), is proportional to exp(-u(x)).
Metropolis-Hastings is neat as it gives you a way to sample from p even if you cannot compute Z or sample from q --- you just need to have some way to sample a proposed a new candidate state x' from x (this proposal distribution doesn't need to have any relationship to the distributions p & q you're actually interested in). Can often think of the proposed candidate state x' as some kind of local mutation of x. Provided you can compute q(x') / q(x), you can use that ratio as a probability of accepting the move to replace x with candidate x'.
By the algorithm depending on the ratio of probabilities of two different states p(x') / p(x) = q(x') / q(x), it lets you sample from p even if you can't compute Z or have any direct way to sample from p or q. *
Metropolis-Hastings & Markov Chain Monte Carlo methods are definitely in the territory of clever 'what to do if you don't know what to do' methods --- if there's some other more direct & practical way of computing the thing you're trying to compute, use that instead! But if there's not, & you have some gnarly problem, maybe MCMC might be the best option available.
* caveat caveat caveat: provided you let the sampler run long enough for it to 'burn in', & perhaps restart it a few times from different initial states x_0 to reduce the chance of it getting trapped in some unrepresentative local optima
psunavy03 1 hours ago [-]
Ironically, there have been studies done in using Monte Carlo methods to predict software delivery timelines (Dan Vacanti and Prateek Singh's work specifically), that found out that the more mature and well-behaved your pipelines and test automation were, the more accurate a naive Monte Carlo simulation was.
The only teams where Markov Chain methods or messing with sampling dates would provide more accurate timelines were the teams whose delivery processes were the most borked and spiky.
positron26 5 hours ago [-]
> Can't differentiate the function? Fuck gradients. Here's the entire fucking posterior.
- Monte Carlo
psunavy03 1 hours ago [-]
"We have no idea why the fuck these neutrons are doing what they're doing, because we haven't figured the physics out yet, but we realized we can still statistically simulate what they're going to do to a good enough level of probability."
That's literally why they invented Monte Carlo as part of the Manhattan Project.
If you enjoyed reading about how you can approximate complex statistical values using basic programming, I highly recommend Jake Vanderplas "Statistics for Hackers" [0][1].
It converts the sometimes hard to grok statistics terms and formulas into some very simple loops and basic operations.
Can't recommend it enough.
0 - https://speakerdeck.com/pycon2016/jake-vanderplas-statistics...
1 - https://www.youtube.com/watch?v=Iq9DzN6mvYA
https://github.com/rohan-sawhney/mcgp-resources
https://github.com/jgrazian/finplan
Try it live: https://finplan.rayknot.com
What do you mean? The retirement planning with Monte-Carlo gave a better result than the base assumption of 4% returns and 2% inflation. The information MC provides let's you, when taking into account your risk threshold, whether you're satisfied with your savings or not by giving you more realistic odds of how long the money will last.
I don’t have reason to believe that 40 years in a row would all have randomly and independently chosen results from a distribution (pure Monte Carlo) as a better model than past actual results.
If you acknowledge that assumption, then you have to choose what model of the historical market you want to use a predictor for the future.
You can use exact market data, test retiring out at every single possible year at every possible asset allocation and see what happens. This is the basis of the 4% rule from Bill Bingham.
You can pull random years out of history and string them together a bunch of times and see what happens with a given asset allocation. This is a naive Monte Carlo simulation.
You can pull blocks of years and string them together, to acknowledge that there are repeating trends in years (what happens in one years influences the next) and do a Monte Carlo simulation which is a bit less naive.
There are more esoteric models overly smart people have constructed, each of which will give you slightly different answers for a safe withdraw rate.
At the end of the day though we are all just crossing our fingers, and hoping for a black swan catastrophe to not happen.
1) rejection sampling - this is the name to the general technique used in the first example, to estimate pi by sampling from a uniform distribution over a unit square (easy) and then rejecting the samples that fall outside of the distribution you're actually interested in (unit disk).
Another simple example of rejection sampling is if you want to randomly pick between 5 ordered options and only have a d6. Roll the d6. If you roll a 6, reject the roll & re-roll. If you roll 1-5, that's your choice.
2) the Metropolis-Hastings algorithm -- this is a Markov chain Monte Carlo algorithm. It can be useful in some applications to sample from a distribution that is difficult to sample from.
Suppose you have some system described by a state vector x & you know that the probability of the system being in state x, p(x), is proportional to q(x), where q is some function you can compute. If you could integrate q over x, to give Z := integral_{x in X} q(x) dx then you'd have p(x) = Z^-1 q(x)
For a concrete example, x might be a state vector of a physical system -- say a bunch of molecules in a box, where you can compute the energy of any given state u(x) and know the probability of x, p(x), is proportional to exp(-u(x)).
Metropolis-Hastings is neat as it gives you a way to sample from p even if you cannot compute Z or sample from q --- you just need to have some way to sample a proposed a new candidate state x' from x (this proposal distribution doesn't need to have any relationship to the distributions p & q you're actually interested in). Can often think of the proposed candidate state x' as some kind of local mutation of x. Provided you can compute q(x') / q(x), you can use that ratio as a probability of accepting the move to replace x with candidate x'.
By the algorithm depending on the ratio of probabilities of two different states p(x') / p(x) = q(x') / q(x), it lets you sample from p even if you can't compute Z or have any direct way to sample from p or q. *
Metropolis-Hastings & Markov Chain Monte Carlo methods are definitely in the territory of clever 'what to do if you don't know what to do' methods --- if there's some other more direct & practical way of computing the thing you're trying to compute, use that instead! But if there's not, & you have some gnarly problem, maybe MCMC might be the best option available.
* caveat caveat caveat: provided you let the sampler run long enough for it to 'burn in', & perhaps restart it a few times from different initial states x_0 to reduce the chance of it getting trapped in some unrepresentative local optima
The only teams where Markov Chain methods or messing with sampling dates would provide more accurate timelines were the teams whose delivery processes were the most borked and spiky.
- Monte Carlo
That's literally why they invented Monte Carlo as part of the Manhattan Project.