由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Mathematics版 - long time generating truncated gamma distribution in python (转载)
相关主题
find distribution paramters only by data mean and std. dev. (转载)请wavelet的专家进来指教一下,谢谢 (转载)
how to do data fitting to find distribution (转载)老张的素数Bounded Gap 衍伸出这样一个问题
这个函数的upper 和 lower bounds是什么呀请教:algebra VS. sigma algebra
跟各位大牛请教一个关于微分算子特征向量扰动的问题有用singular软件或者搞invariant polynomial theory的吗?
Lp space and compact seta statistics interview question
请教一个定理证明中的问题急:一个normal distribution 加一个truncated normal distribu
请教一个operator norm的问题question about the sum of truncated normal rv (转载)
isometry请教dispersive equations的研究情况
相关话题的讨论汇总
话题: shape话题: bins话题: scale话题: gamma话题: truncated
进入Mathematics版参与讨论
1 (共1页)
m******t
发帖数: 273
1
【 以下文字转载自 Statistics 讨论区 】
发信人: myregmit (myregmit), 信区: Statistics
标 题: long time generating gamma distribution in python
发信站: BBS 未名空间站 (Thu Mar 13 19:04:24 2014, 美东)
I need to generate a truncated gamma distribution pdf curve and histogram in
python 3.
2 on win7.
import numpy as np
import matplotlib.pyplot as plt
import scipy.special as sps
shape, scale = 2., 2. # mean and dispersion
counter =0
s = []
upper_bound = 4
lower_bound = 0.5
while (counter <= 1000):
t = np.random.gamma(shape, scale, 1)
if (lower_bound <= t <= upper_bound) :
s.append(t)
counter += 1
count, bins, ignored = plt.hist(s, 50, normed=True)
// this part take s very long time
y = bins**(shape-1)*(np.exp(-bins/scale) /
(sps.gamma(shape)*scale**shape))
plt.plot(bins, y, linewidth=2, color='r')
plt.show()
I find that "y = bins*(shape-1)(np.exp(-bins/scale) / (sps.gamma(shape)scale
*shape))"
take very long time and the pop-up figure window becomes no-responding.
If I remove the lower and upper bounds for the gamma distribution, it runs
very fast.
Any help would be appreciated.
Thanks !
1 (共1页)
进入Mathematics版参与讨论
相关主题
请教dispersive equations的研究情况Lp space and compact set
级数是无穷项的和吧?请教一个定理证明中的问题
Re: 请教:这个不等式如何证明?请教一个operator norm的问题
How to calculate det(A)???[合集]isometry
find distribution paramters only by data mean and std. dev. (转载)请wavelet的专家进来指教一下,谢谢 (转载)
how to do data fitting to find distribution (转载)老张的素数Bounded Gap 衍伸出这样一个问题
这个函数的upper 和 lower bounds是什么呀请教:algebra VS. sigma algebra
跟各位大牛请教一个关于微分算子特征向量扰动的问题有用singular软件或者搞invariant polynomial theory的吗?
相关话题的讨论汇总
话题: shape话题: bins话题: scale话题: gamma话题: truncated