简体   繁体   中英

How do I generate data with specified mean, variance, skewness, kurtosis in Python?

I want to generate data in Python that behaves like real stock market data, which means I need to be able to specify and play around with all of the first four moments. Only being able to control skewness or only kurtosis is unfortunately not enough.

I found some answers here: How to generate a distribution with a given mean, variance, skew and kurtosis in Python? , however I seem unable to gain control of the properties with the gengamma distribution.

I know there are tons of distributions here: https://docs.scipy.org/doc/scipy/reference/stats.html#continuous-distributions , maybe I can use one of them in some clever way? Or is there another way?

I think you are better using the gengamma function in scipy since you have all the parameters to control the shape of the distribution.

from scipy.stats import gengamma

https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.gengamma.html

Hopes this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM