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

yipeiwu_com6年前Python基础

如下所示:

# 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 捕获 shell/bash 脚本的输出结果实例

#!/usr/bin/python ## get subprocess module import subprocess   ## call date command ##...

Python安装及Pycharm安装使用教程图解

Python安装及Pycharm安装使用教程图解

1.计算机语言的基本概念 计算机语言(Computer Language) 指用于人与计算机之间的通信。 2.解释型和编译型语言的区别 编译型语言:如:C C++ (1)、只须编译一次就...

python解决js文件utf-8编码乱码问题(推荐)

html文件中引入js文件,显示乱码! js文件为utf-8 编码(无bom)  ,此时只要将js文件转成utf-8 BOM编码就可以解决了 可以使用notepad++转码 也...

Python + selenium + requests实现12306全自动抢票及验证码破解加自动点击功能

Python + selenium + requests实现12306全自动抢票及验证码破解加自动点击功能

测试结果:  整个买票流程可以再快一点,不过为了稳定起见,有些地方等待了一些时间 完整程序,拿去可用 整个程序分了三个模块:购票模块(主体)、验证码识别模块、余票查询模块...

django框架防止XSS注入的方法分析

本文实例讲述了django框架防止XSS注入的方法。分享给大家供大家参考,具体如下: XSS 是常见的跨站脚本攻击,而且这种类型的错误很不容易被发现或者被开发人员忽视,当然django...