Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a custom probability distribution to draw random samples from in SciPy [duplicate]

I'm looking to sum up an arbitrary number of probabilistic distributions of things using a montecarlo type simulation. I'd like to randomly sample continuous distributions of something and add them to other random samples of other continuous distributions, ultimately getting a probability distribution for their combination. The distributions themselves are empirical - they aren't a function but in the form of P99 = 2.4, P90 = 7.12, P50 = 24.53, P10 = 82.14 and so on (in reality there are a bunch of those points). The distributions are more or less lognormal, so approximating them as lognormal would probably be fine, if that's necessary. But how could I enter that into SciPy's lognorm function? Or do it some other way in SciPy, or python in general?

I hope it's clear what I'm trying to do. Thanks a lot, Alex

like image 211
Alex S Avatar asked Apr 17 '13 22:04

Alex S


1 Answers

It looks like what you have is essentially a histogram of the probability density. One thing you can do then is to use the inverse transform sampling with your empirical distribution.

As an alternative, if you expect a certain functional form of a distribution (lognorm or some other one), you can try fitting the data with the corresponding functional form.

like image 142
ev-br Avatar answered Sep 30 '22 13:09

ev-br