Pull Random Numbers from my Data (Python)

Let's imagine I have a series of numbers that represents cash flows into some account over the past 30 days in some time window. This data is non-normal but it does represent some distribution. I would like to pull new numbers from this distribution in an effort to create a monte-carlo simulation based on the numerical data I have. How can I accomplish this? I've seen methods where you assume the data is normal pull numbers based on some mean and standard deviation - but what about non-normal distributions? I'm using python so any reference including python or some python libraries would be appreciated.

Topic monte-carlo simulation python statistics

Category Data Science


If what you want is to generate random numbers with the same distribution as your cashflow numbers I recommend you using Python's Fitter package

It is powerful and very simple to use.

You can in this way use it to find the distribution of your data and then generate random numbers with the same distribution.

From documentation:

from scipy import stats
data = stats.gamma.rvs(2, loc=1.5, scale=2, size=10000)

from fitter import Fitter
f = Fitter(data)
f.fit()
# may take some time since by default, all distributions are tried
# but you call manually provide a smaller set of distributions
f.summary()

Also useful resources might be found in stackoverflow

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.