当前位置:网站首页>MCS: discrete random variable Poisson distribution
MCS: discrete random variable Poisson distribution
2022-06-29 15:13:00 【Fight the tiger tonight】
Poisson
When the event is within a specified time interval ( Unit time ), At a fixed average instantaneous rate ( The average number of occurrences ) θ \theta θ happen , Then the variable describing the number of events per unit time is Poisson variable . Poisson distribution is suitable for describing the number of random events per unit time , for example : The number of vehicles passing the intersection per minute ; The number of passengers waiting at the station every hour ;
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,...
Expectation and variance :
E ( x ) = θ E(x) = \theta E(x)=θ
V ( x ) = θ V(x) = \theta V(x)=θ
Poisson variable & Exponential variable : t t t
E ( t ) = 1 θ E(t) = \frac{1}{\theta} E(t)=θ1
Generate random Poisson variables
Generate random Poisson variables x x x, And E ( x ) = V ( x ) = θ E(x) = V(x) = \theta E(x)=V(x)=θ
- Make 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, Generate random exponential variables : t t t, And 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
example : hypothesis x x x Is a random variable subject to Poisson distribution , The expected number of events per unit time is θ = 2.4 \theta = 2.4 θ=2.4, Let's use the exponential variable t t t,( E ( t ) = 1 / 2.4 E(t) = 1/2.4 E(t)=1/2.4) To generate Poisson variables :
- Make 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
example : One 24 A gas station that is open 24 hours , Every day 200-300 A car came here to refuel , among 80% It's a car ,15% It's a truck ,5% It's a motorcycle . The minimum gasoline consumption per car is 3 Gallon , The average is 11 Gallon . Trucks consume at least 8 Gallon , The average is 20 Gallon . Motorcycles consume at least 2 Gallon , The average is 4 Gallon . Analysts want to figure out the distribution of the total consumption of gas stations in a day .
Simulate the future with random numbers 1000 God , Gasoline consumption in gas stations , The type of vehicle and the amount of fuel consumed are generated by random numbers .
- Record analog data , Total fuel consumption per day G G G
- Sort from small to large , G ( 1 ) < = G ( 2 ) < = G ( 3 ) < = . . . G ( 1000 ) G(1) <= G(2) <= G(3) <= ...G(1000) G(1)<=G(2)<=G(3)<=...G(1000)
- Estimated quantile : 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 |
Simulation results :
- The daily oil consumption exceeds 3536 The probability of gallons is :5%
- The daily fuel consumption exceeds 3616 The probability of gallons is :1%
- Daily fuel consumption 90% The interval is : P ( 2447 < = G < = 3536 ) = 0.90 P(2447 <= G <= 3536) = 0.90 P(2447<=G<=3536)=0.90
边栏推荐
- 阿尔兹海默病智能诊断
- 卫龙更新招股书:年营收48亿 创始人刘卫平家族色彩浓厚
- The first lesson on cloud - how easy is it to build a small broken station? The old driver of cloud computing will take you one hour to finish it
- 熊市慢慢,Bit.Store提供稳定Staking产品助你穿越牛熊
- 三角函数对应在平面坐标上画圆
- phpcms打开后台首页时向官网发送升级请求觉得卡怎么办?
- Redis installation in windows and Linux Environment
- Create an API rapid development platform, awesome!
- Informatics Olympiad all in one 2062: movie tickets
- EMC-浪涌防护及退耦设计
猜你喜欢

curl: (56) Recv failure: Connection reset by peer

Construction and application of medical field Atlas of dingxiangyuan

CKS CKA CKAD 将终端更改为远程桌面

Lumiprobe 脱氧核糖核酸丨炔烃dT亚磷酰胺

How bad can a programmer be?

mysql 备份与还原

Netease strict selection offline data warehouse quality construction practice

Pytorch two-dimensional multi-channel convolution operation method

Secondary pointer

Lumiprobe 点击化学丨非荧光炔烃:己酸STP酯
随机推荐
Hi,你有一份Code Review攻略待查收
Lumiprobe click chemistry - non fluorescent azide: azide-peg3-oh
go学习(四、面向接口)
How does a two character name become a three character name with spaces
Digital IC code -- traffic lights
打造一个 API 快速开发平台,牛逼!
Chapter IX app project test (4) test tools
目前股票开户安全吗?可以直接网上开户吗
Lumiprobe 点击化学丨非荧光炔烃:己酸STP酯
信息学奥赛一本通1003:对齐输出
又拍云 Redis 的改进之路
curl: (56) Recv failure: Connection reset by peer
mysql 备份与还原
我 35 岁,可以转行当程序员吗?
Konva series Tutorial 4: drawing attributes
Huashu high tech rushes to the scientific innovation board: the actual controller xuxiaoshu and his son, who plan to raise 660million yuan, are both American nationals
phpcms打开后台首页时向官网发送升级请求觉得卡怎么办?
For example, the visual appeal of the live broadcast of NBA Finals can be seen like this?
[Verilog quick start of Niuke online question series] ~ shift operation and multiplication
中国三氧化二砷行业研究与未来预测报告(2022版)