2024-07-07 07:30:24 发布
网友
random.gauss(mu, sigma)
上面的函数允许从正态分布中随机抽取一个给定均值和方差的数。但是,我们如何才能从一个正态分布中得出值,这个正态分布定义的不仅仅是两个初始时刻?
类似于:
random.gauss(mu, sigma, skew, kurtosis)
使用scipy怎么样?您可以从continuous distributions in the scipy.stats library中选择所需的分发。
广义gamma函数有非零的歪斜和峰度,但是您需要做一点工作来确定要使用哪些参数来指定分布以获得特定的均值、方差、歪斜和峰度。这里有一些代码让你开始。
import scipy.stats import matplotlib.pyplot as plt distribution = scipy.stats.norm(loc=100,scale=5) sample = distribution.rvs(size=10000) plt.hist(sample) plt.show() print distribution.stats('mvsk')
这将显示正态分布中10000个元素样本的直方图,均值为100,方差为25,并打印分布的统计信息:
(array(100.0), array(25.0), array(0.0), array(0.0))
用广义伽马分布代替正态分布
distribution = scipy.stats.gengamma(100, 70, loc=50, scale=10)
你得到统计数据[均值,方差,偏斜,峰度] (array(60.67925117494595), array(0.00023388203873597746), array(-0.09588807605341435), array(-0.028177799805207737))。
(array(60.67925117494595), array(0.00023388203873597746), array(-0.09588807605341435), array(-0.028177799805207737))
试着使用这个:
http://statsmodels.sourceforge.net/devel/generated/statsmodels.sandbox.distributions.extras.pdf_mvsk.html#statsmodels.sandbox.distributions.extras.pdf_mvsk
Return the Gaussian expanded pdf function given the list of 1st, 2nd moment and skew and Fisher (excess) kurtosis.Parameters : mvsk : list of mu, mc2, skew, kurt
Return the Gaussian expanded pdf function given the list of 1st, 2nd moment and skew and Fisher (excess) kurtosis.
Parameters : mvsk : list of mu, mc2, skew, kurt
我觉得不错。在那一页上有一个指向源代码的链接。
哦,还有另一个StackOverflow问题让我明白了: Apply kurtosis to a distribution in python
使用scipy怎么样?您可以从continuous distributions in the scipy.stats library中选择所需的分发。
广义gamma函数有非零的歪斜和峰度,但是您需要做一点工作来确定要使用哪些参数来指定分布以获得特定的均值、方差、歪斜和峰度。这里有一些代码让你开始。
这将显示正态分布中10000个元素样本的直方图,均值为100,方差为25,并打印分布的统计信息:
(array(100.0), array(25.0), array(0.0), array(0.0))
用广义伽马分布代替正态分布
你得到统计数据[均值,方差,偏斜,峰度]
(array(60.67925117494595), array(0.00023388203873597746), array(-0.09588807605341435), array(-0.028177799805207737))
。试着使用这个:
http://statsmodels.sourceforge.net/devel/generated/statsmodels.sandbox.distributions.extras.pdf_mvsk.html#statsmodels.sandbox.distributions.extras.pdf_mvsk
我觉得不错。在那一页上有一个指向源代码的链接。
哦,还有另一个StackOverflow问题让我明白了: Apply kurtosis to a distribution in python
相关问题 更多 >
编程相关推荐