当前位置:网站首页>MCS:离散随机变量——Poisson分布
MCS:离散随机变量——Poisson分布
2022-06-29 14:39:00 【今晚打佬虎】
Poisson
当事件在指定的时间间隔内(单位时间),以固定平均瞬时速率(平均发生次数) θ \theta θ发生,那么描述这个单位时间内事件发生次数的变量就是泊松变量。泊松分布适合于描述单位时间内随机事件发生的次数,例如:每分钟经过十字路口的车辆数量;没小时车站的候客人数;
P ( x ) = θ x e − θ x ! , x = 0 , 1 , 2 , . . . P(x) = \frac{\theta^x e^{-\theta}}{x!},x = 0, 1, 2, ... P(x)=x!θxe−θ,x=0,1,2,...
期望和方差:
E ( x ) = θ E(x) = \theta E(x)=θ
V ( x ) = θ V(x) = \theta V(x)=θ
泊松变量&指数变量: t t t
E ( t ) = 1 θ E(t) = \frac{1}{\theta} E(t)=θ1
生成随机泊松变量
生成随机泊松变量 x x x,且 E ( x ) = V ( x ) = θ E(x) = V(x) = \theta E(x)=V(x)=θ
- 令 x = 0 , i = 0 , S t = 0 x = 0, i = 0, S_t = 0 x=0,i=0,St=0
- i = i + 1 i = i + 1 i=i+1,生成随机指数变量: t t t,且 E ( t ) = 1 / θ E(t) = 1/\theta E(t)=1/θ, S t = S t + t S_t = S_t + t St=St+t
- if S t > 1 S_t > 1 St>1, → s t e p 5 \to step5 →step5
- if S t < = 1 , x = x + 1 S_t <= 1, x = x + 1 St<=1,x=x+1, → s t e p 2 \to step2 →step2
- Return x x x
例:假设 x x x为服从泊松分布的随机变量,单位时间内事件发生的期望次数为 θ = 2.4 \theta = 2.4 θ=2.4,下面通过指数变量 t t t,( E ( t ) = 1 / 2.4 E(t) = 1/2.4 E(t)=1/2.4)来生成泊松变量:
- 令 x = 0 , S t = 0 x = 0, S_t = 0 x=0,St=0
- i = 1 , t = 0.21 , S t = 0.21 , x = 1 i = 1,t = 0.21,S_t = 0.21,x = 1 i=1,t=0.21,St=0.21,x=1
- i = 2 , t = 0.43 , S t = 0.64 , x = 2 i = 2,t = 0.43,S_t = 0.64,x = 2 i=2,t=0.43,St=0.64,x=2
- i = 3 , t = 0.09 , S t = 0.73 , x = 3 i = 3,t = 0.09,S_t = 0.73,x = 3 i=3,t=0.09,St=0.73,x=3
- i = 4 , t = 0.31 , S t = 1.04 , x = 4 i = 4,t = 0.31,S_t = 1.04,x = 4 i=4,t=0.31,St=1.04,x=4
- x = 3 x = 3 x=3
例:一个24小时营业的加油站,每天有200-300辆车来这里加油,其中80%是汽车,15%是卡车,5%是摩托车。每辆汽车消耗汽油最小是3加仑,平均是11加仑。卡车消耗汽油最少是8加仑,平均是20加仑。摩托车消耗的汽油最少是2加仑,平均是4加仑。分析员想弄清楚加油站一天之内消耗总量的分布情况。
用随机数模拟未来1000天,加油站汽油消耗情况,车辆的类型和消耗的油量通过随机数生成。
- 记录模拟数据,每天的耗油总量 G G G
- 从小到大排序, G ( 1 ) < = G ( 2 ) < = G ( 3 ) < = . . . G ( 1000 ) G(1) <= G(2) <= G(3) <= ...G(1000) G(1)<=G(2)<=G(3)<=...G(1000)
- 估计分位数: G ( p × 1000 ) G(p \times 1000) G(p×1000), p = 0.01 , G ( 0.01 × 1000 ) = G ( 10 ) p = 0.01, G(0.01 \times 1000) = G(10) p=0.01,G(0.01×1000)=G(10)
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
def gas_consum_oneday():
num_vehicle = np.clip(np.random.poisson(300), 200, 500)
num_cars = int(num_vehicle * 0.8)
num_trucks = int(num_vehicle * 0.15)
num_motos = num_vehicle - (num_cars + num_trucks)
car_consume = [np.random.randint(3, 19) for i in range(num_cars)]
truck_consume = [np.random.randint( 8, 32) for i in range(num_trucks)]
moto_consume = [np.random.randint( 2, 6) for i in range(num_motos)]
sum_gas = np.sum(car_consume + truck_consume + moto_consume)
return num_vehicle, num_cars, num_trucks, num_motos, sum_gas
| vehicle_record | cars_record | trucks_record | motos_record | gas_record | P | |
|---|---|---|---|---|---|---|
| 9 | 201 | 160 | 30 | 11 | 2362 | 0.01 |
| 49 | 202 | 161 | 30 | 11 | 2447 | 0.05 |
| 99 | 213 | 170 | 31 | 12 | 2498 | 0.10 |
| 199 | 215 | 172 | 32 | 11 | 2617 | 0.20 |
| 299 | 228 | 182 | 34 | 12 | 2723 | 0.30 |
| 399 | 245 | 196 | 36 | 13 | 2841 | 0.40 |
| 499 | 254 | 203 | 38 | 13 | 2965 | 0.50 |
| 599 | 259 | 207 | 38 | 14 | 3089 | 0.60 |
| 699 | 262 | 209 | 39 | 14 | 3199 | 0.70 |
| 799 | 276 | 220 | 41 | 15 | 3332 | 0.80 |
| 899 | 288 | 230 | 43 | 15 | 3468 | 0.90 |
| 949 | 297 | 237 | 44 | 16 | 3536 | 0.95 |
| 989 | 299 | 239 | 44 | 16 | 3616 | 0.99 |
模拟结果:
- 日消耗油量超过3536加仑的概率为:5%
- 日耗油量超过3616加仑概率为:1%
- 日耗油90%的区间为: P ( 2447 < = G < = 3536 ) = 0.90 P(2447 <= G <= 3536) = 0.90 P(2447<=G<=3536)=0.90
边栏推荐
- How does a two character name become a three character name with spaces
- 网易严选离线数仓质量建设实践
- Differences between @resource and @autowired annotations automatically injected:
- What should phpcms do when it sends an upgrade request to the official website when it opens the background home page?
- 华曙高科冲刺科创板:拟募资6.6亿 实控人许小曙父子均为美国籍
- MCS:离散随机变量——Binomial分布
- MCS:离散随机变量——Hyper Geometric分布
- 《canvas》之第7章 变形操作
- 仿头条新闻资讯dz模板 Discuz新闻资讯商业版GBK模板源码
- FIFO implementation with single port RAM
猜你喜欢

Draw a slash on a plane coordinate
![[practical chapter of correlation analysis] why can't Bi software do correlation analysis](/img/f2/4f99deb63b1beffae90b8a1fb270d1.png)
[practical chapter of correlation analysis] why can't Bi software do correlation analysis

【Try to Hack】vulnhub DC2

Zhimeng dedecms resource material tutorial download website template source code (with mobile terminal) with installation tutorial
![[top] blog instructions, bulletin board, message board, about bloggers](/img/3a/6100ae88874cad57305decce41c1e7.png)
[top] blog instructions, bulletin board, message board, about bloggers

ROS 笔记(10)— launch 文件启动

Stm32 mbed tutorial (IV) --pwm

Whitelabel Error Page访问

Configuration tutorial for swagger2

【Try to Hack】vulnhub DC2
随机推荐
Chapter 6 picture operation of canvas
Paper study -- accurate accounting of annual total runoff control rate considering the interannual variation characteristics of rainfall
Chapter 12 other applications of canvas
Laravel - composer installs the specified laravel version
Deploy redis sentry in k8s
MCS:离散随机变量——Hyper Geometric分布
Chapter 14 of canvas physical animation
You need to know about project procurement management
【关联分析实战篇】为什么 BI 软件都搞不定关联分析
两个字的名字如何变成有空格的3个字符的名字
k8s部署redis哨兵
利用多态实现简单的计算器
Imitation headline news information DZ template discuz news information business version GBK template source code
类模板案例-【数组类封装】
Query function of Excel vlookup
中国三氧化二砷行业研究与未来预测报告(2022版)
China soft ice cream market forecast and investment prospect research report (2022 Edition)
Chapter 10 of canvas path
How does a two character name become a three character name with spaces
mysql 备份与还原