126 points ibobev 3 days ago 23 comments
theOGognf 14 hours ago | parent
alexpotato 13 hours ago | parent
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...
wodenokoto 2 hours ago | parent
A few years after watching it for the first time I rewatched it and paused after every problem statement and tried implementing a “simple loops and basic operations” solution and failed almost every single time.
So be warned: he does make it look easy :)
alexpotato 41 minutes ago | parent
"Before they had functions and lookup tables, what would a human have done in the 1940s?"
e.g. the statistical significance is just "if I were to randomly try this, what percentage of time would it be above 5%"
avadodin 1 hour ago | parent
> I know, I will use rand
> noo, do you even know a thing about randomness?
> okay, fine. I'll use arc4rand which uses a cryptographically-sound prng
> nooo! Random numbers are crap! you should use space-filling sequences that are guaranteed to work optimally for infinity dimensions
> okay
Billy, what are you rambling about? Wake up! We already have a result using RANDU that the verification process confirms is correct.
hingler36 13 hours ago | parent
positron26 13 hours ago | parent
- Monte Carlo
psunavy03 9 hours ago | parent
That's literally why they invented Monte Carlo as part of the Manhattan Project.
coderenegade 8 hours ago | parent
stevenhubertron 12 hours ago | parent
Jtsummers 12 hours ago | parent
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.
lastofus 11 hours ago | parent
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.
sokoloff 10 hours ago | parent
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.
_Bruno42 12 hours ago | parent
charlieyu1 12 hours ago | parent
shoo 11 hours ago | parent
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 9 hours ago | parent
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.
nxobject 10 hours ago | parent
ViscountPenguin 7 hours ago | parent
tugboatt 10 hours ago | parent
https://github.com/jgrazian/finplan
Try it live: https://finplan.rayknot.com
pizzathyme 8 hours ago | parent
physix 5 hours ago | parent
I wrote Monte-Carlo simulations to calculate the thermodynamics of oxygen ordering in a high temperature superconductor way back in 1993.
Calculating thermodynamic fluctuations on a 256x256 lattice took all night. And that, even though it ran on an HP 9000/750 with a 66 MHz PA-7000 (PA-RISC 1.1) 32-bit CPU.
While waiting, I used to look at weather satellite images downloaded from CERN using NCSA Mosaic. It was impressive. All the information available at your fingertips by using arrow keys and pressing return on underlined text to navigate to the next page! Emmm, link.
fithisux 5 hours ago | parent
[1]: https://austinrochford.com/posts/intro-prob-prog-pymc.html [2]: https://vincentk1991.github.io/Bayesian-regression-tutorial/
I can't recommend enough
[3]: https://academic.oup.com/book/54722
the best book on the subject with a Coursera series of top quality