【问题标题】:How to calculate the probability of a random variable falling into a given interval that is distributed over the Cauchy distribution如何计算随机变量落入分布在柯西分布上的给定区间的概率
【发布时间】:2018-07-16 12:38:07
【问题描述】:

我知道,如果我想获得从 inteval ab 的概率值,我必须从 pdf 我的分布计算积分。我知道我的数据具有柯西分布,但我不明白如何获得区间概率,例如从 95100。我怎样才能做到简单或简单是不可能的?

我的分布历史代码:

# Display
plt.figure(figsize=(15,10))
ax = pdf.plot(lw=2, label='PDF', legend=True)
data.plot(kind='hist', bins=50, normed=True, label='Data', legend=True, 
ax=ax, lw=2, color='g', alpha=0.4)
mu, std = norm.fit(data)
param_names = (best_dist.shapes + ', loc, scale').split(', ') if 
best_dist.shapes else ['loc', 'scale']
param_str = ', '.join(['{}={:0.2f}'.format(k,v) for k,v in zip(param_names, 
best_fir_paramms)])
dist_str = '{}(mu = {:0.2f}, std = {:0.2f})'.format(best_fit_name, mu, std)
ax.set_title(u'Distribution \n' + dist_str)
ax.set_ylabel('F(x)')

hist of distribution

我的历史值代码:

ser = Series(df)
out = pd.cut(ser, bins=[0, 85, 90, 92, 94, 96, 98, 100], include_lowest=True)
ax = out.value_counts(sort=False).plot.bar(rot=0, color='g', alpha=0.4, 
title='Values', figsize=(10,8))
ax.set_xticklabels([c[1:-1].replace(',',' to') for c in out.cat.categories])
plt.show()

hist values

我想得到从 90 到 100 的概率区间值。我如何通过 python 来做到这一点。谢谢。

【问题讨论】:

    标签: python pandas matplotlib probability


    【解决方案1】:

    查看数字是否介于 118 和 154 之间:

    from scipy.stats import cauchy
    print(cauchy.cdf(154) - cauchy.cdf(118));
    

    回答 0.000630558571138,您的 RV 在这两个数字之间的概率

    【讨论】:

    猜你喜欢
    • 2012-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-02
    • 1970-01-01
    • 1970-01-01
    • 2011-09-30
    • 2017-06-05
    相关资源
    最近更新 更多