由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - how to generate truncated gamma distribution in pytho
相关主题
find distribution paramters only by data mean and std. dev.About Gamma Distribution
问牛人们一个求posterior期望的问题C programming in statistics
请教一个积分,大家帮忙看看能积出来么。求助:一道统计证明题
how to do data fitting to find distribution (转载)菜鸟问题:想用R画一个random sequence的图
能用模型拟合或预测debt collection吗?如何print比较长的column ‘WARNING: Data too long for column; truncated to 92 characters to fi
model simplex distributionquestion about proc format
normality test of a set of data?model fit的疑难杂症: negative binomial regression 求指点
报面经,顺便问问大牛,两个intern offer选哪个##如果logistic回归自变量x不是线性的,怎么办?##
相关话题的讨论汇总
话题: bins话题: shape话题: truncated话题: bound话题: gamma
进入Statistics版参与讨论
1 (共1页)
m******t
发帖数: 273
1
I need to generate a truncated gamma distribution pdf curve and histogram in
python 3.2 on win7.
The following program is correct ?
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)
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()
Any help would be appreciated.
Thanks !
1 (共1页)
进入Statistics版参与讨论
相关主题
##如果logistic回归自变量x不是线性的,怎么办?##能用模型拟合或预测debt collection吗?
R package: how to use xx.rd files to generate PDF document?model simplex distribution
在R里怎么跳到指定的地方?normality test of a set of data?
how to save dataset generated by a function in R报面经,顺便问问大牛,两个intern offer选哪个
find distribution paramters only by data mean and std. dev.About Gamma Distribution
问牛人们一个求posterior期望的问题C programming in statistics
请教一个积分,大家帮忙看看能积出来么。求助:一道统计证明题
how to do data fitting to find distribution (转载)菜鸟问题:想用R画一个random sequence的图
相关话题的讨论汇总
话题: bins话题: shape话题: truncated话题: bound话题: gamma