首页 > 数据分析

python-numpy-指数分布实例详解

时间:2021-01-20 数据分析 查看: 893

如下所示:

# Seed random number generator
np.random.seed(42)

# Compute mean no-hitter time: tau
tau = np.mean(nohitter_times)

# Draw out of an exponential distribution with parameter tau: inter_nohitter_time
inter_nohitter_time = np.random.exponential(tau, 100000)

# Plot the PDF and label axes
_ = plt.hist(inter_nohitter_time,
    bins=50, normed=True, histtype='step')
_ = plt.xlabel('Games between no-hitters')
_ = plt.ylabel('PDF')

# Show the plot
plt.show()

指数分布的拟合

# Create an ECDF from real data: x, y
x, y = ecdf(nohitter_times)

# Create a CDF from theoretical samples: x_theor, y_theor
x_theor, y_theor = ecdf(inter_nohitter_time)

# Overlay the plots
plt.plot(x_theor, y_theor)
plt.plot(x, y, marker='.', linestyle='none')

# Margins and axis labels
plt.margins(0.02)
plt.xlabel('Games between no-hitters')
plt.ylabel('CDF')

# Show the plot
plt.show()

以上这篇python-numpy-指数分布实例详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持python博客。

展开全文
上一篇:Python Sympy计算梯度、散度和旋度的实例
下一篇:Python数据可视化:泊松分布详解
输入字:
相关知识
python数据挖掘使用Evidently创建机器学习模型仪表板

在本文中,我们将探索 Evidently 并创建交互式报告/仪表板。有需要的朋友欢迎大家收藏学习,希望能够有所帮助,祝大家多多进步早日升职加薪

Python多进程共享numpy 数组的方法

本文章主要介绍了Python多进程共享numpy 数组的方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

python数据分析近年比特币价格涨幅趋势分布

这篇文章主要为大家介绍了python分析近年来比特币价格涨幅趋势的数据分布,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步

python调用matlab的方法详解

这篇文章主要为大家介绍了python调用matlab,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能够给你带来帮助