当前位置:网站首页>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
边栏推荐
- 威高血液净化冲刺香港:年营收29亿 净利降12.7%
- symfony框架安全组件(security)防火墙配置
- Lumiprobe 活性染料丨氨基染料:花青5胺
- MySQL的json 数组操作 json_array_append、json_array_insert
- Northwestern Polytechnic University attacked by overseas e-mail
- 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
- 广州期货正规吗?如果有人喊你用自己的手机登,帮忙开户,安全吗?
- kubernetes Unable to connect to the server: x509: certificate has expired or is not yet valid
- Lumiprobe 活性染料丨羧酸:Sulfo-Cyanine7.5羧酸
- 西北工业大学遭境外电邮攻击
猜你喜欢
随机推荐
材质 动态自发光
【牛客网刷题系列 之 Verilog快速入门】~ 移位运算与乘法
Const usage
Basic use of text preprocessing library Spacy (quick start)
Lumiprobe reactive dye carboxylic acid: sulfo cyanine7.5 carboxylic acid
信息学奥赛一本通1003:对齐输出
Hi,你有一份Code Review攻略待查收
Trigonometric function corresponding to drawing circle on plane coordinate
Konva series Tutorial 4: drawing attributes
Lumiprobe 活性染料丨氨基染料:花青5胺
Alibaba cloud experience Award: use polardb-x and Flink to build a large real-time data screen
mysql 备份与还原
Is Guangzhou futures regular? If someone asks you to log in with your own mobile phone and help open an account, is it safe?
Chapter IX app project test (the end of this chapter)
synchronized 与多线程的哪些关系
curl: (56) Recv failure: Connection reset by peer
Chapter IX app project test (4) test tools
第九章 APP项目测试(此章完结)
Evaluation index of high concurrency software (website, server interface)
Is 100W data table faster than 1000W data table query in MySQL?








