当前位置:网站首页>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
边栏推荐
- Deploy redis sentry in k8s
- 利用多态实现简单的计算器
- 《canvas》之第7章 变形操作
- . Net program configuration file operation (INI, CFG, config)
- 我登录RDB的数据库,提示需要主账号授权,这个我怎么知道该找谁?
- Laravel - Composer 安装指定 Laravel 版本
- Build your own website (19)
- I log in to the RDB database and prompt that the master account authorization is required. How do I know who to call?
- Class template case - array class encapsulation
- 华理生物冲刺科创板:年营收2.26亿 拟募资8亿
猜你喜欢
wieshark抓包mysql协议简单分析
威高血液净化冲刺香港:年营收29亿 净利降12.7%
校园跑腿微信小程序跑腿同学带直播新版源码
Digital IC code -- traffic lights
Practical application cases of drives
Analysis of istio -- observability
Huali biology rushes to the scientific innovation board: the annual revenue is RMB 226million and it is planned to raise RMB 800million
微信公众号—菜单
模电 2个NPN管组成的恒流源电路分析
Transport layer selective ACK
随机推荐
Deploy redis sentry in k8s
You need to know about project procurement management
How does a two character name become a three character name with spaces
mysql 备份与还原
Is 100W data table faster than 1000W data table query in MySQL?
高并发软件(网站,服务器端接口)的评价指标
Redis installation in windows and Linux Environment
EXCEL的查询功能Vlookup
Digital IC code -- traffic lights
I log in to the RDB database and prompt that the master account authorization is required. How do I know who to call?
Chapter 5 text operation of canvas
. Net program configuration file operation (INI, CFG, config)
熊市慢慢,Bit.Store提供稳定Staking产品助你穿越牛熊
Alibaba cloud experience Award: use polardb-x and Flink to build a large real-time data screen
三角函数对应在平面坐标上画圆
Transport layer selective ACK
Whitelabel error page access
[Verilog quick start of Niuke online question series] ~ shift operation and multiplication
The 5th China software open source innovation competition | opengauss track live training
Weigao blood purification sprint to Hong Kong: annual revenue of RMB 2.9 billion, net profit decreased by 12.7%