当前位置:网站首页>MCS:多元随机变量——多项式分布
MCS:多元随机变量——多项式分布
2022-06-29 14:39:00 【今晚打佬虎】
Multinomial多项式
假设一个实验有 k k k个相互独立的结果: R 1 , R 2 , . . . R k R_1, R_2, ... R_k R1,R2,...Rk对应发生的概率分别是: p 1 , p 2 , . . . p k p_1, p_2, ...p_k p1,p2,...pk。且 ∑ i = 1 k p i = 1.0 \sum_{i=1}^k p_i = 1.0 ∑i=1kpi=1.0。独立重复 n n n次实验,每一种实验结果发生的次数可以用随机变量 x 1 , x 2 , . . x k x_1, x_2, .. x_k x1,x2,..xk来表示, ∑ i = 1 k x i = n \sum_{i=1}^k x_i = n ∑i=1kxi=n。
x i x_i xi的概率分布:
P ( x 1 , . . . , x k ) = n ! [ x 1 ! . . . x k ! ] p 1 x 1 . . . p k x k P(x_1, ..., x_k) = \frac{n!}{[x_1!...x_k!]p_1^{x_1} ... p_k^{x_k}} P(x1,...,xk)=[x1!...xk!]p1x1...pkxkn!
x i x_i xi的边际(期望和方差):
E ( x i ) = n p i E(x_i) = np_i E(xi)=npi
V ( x i ) = n p i ( 1 − p i ) V(x_i) = np_i(1 - p_i) V(xi)=npi(1−pi)
生成多项式随机变量
已知:多显示变量: ( x 1 , x 2 , . . . , x k ) (x_1, x_2, ...,x_k) (x1,x2,...,xk),发生的概率: ( p 1 , P 2 , . . . p k ) (p_1, P_2, ...p_k) (p1,P2,...pk)
- i = 1 → k i = 1 \to k i=1→k
- p i ′ = p i / ∑ j = i k p j p_i' = p_i / \sum_{j=i}^k p_j pi′=pi/∑j=ikpj
- n i ′ = n − ∑ j = 1 i − 1 x j n_i' = n - \sum_{j=1}^{i-1} x_j ni′=n−∑j=1i−1xj
- 生成一个随机的二项式变量: x i ∼ B i n o m i a l ( n i ′ , p i ′ ) x_i \sim Binomial(n_i', p_i') xi∼Binomial(ni′,pi′)
- ( x 1 , x 2 , . . . x k ) (x1, x_2, ... x_k) (x1,x2,...xk)
例:假设一个实验只有三种结果可能发生,概率分别是:0.5, 0.3, 0.2。假设重复进行五次的独立实验,这种情况下每种情况出现的次数,即:随机的多项式变量: x 1 , x 2 , x 3 x_1, x_2, x_3 x1,x2,x3可能是多少?
- i = 1 , n 1 ′ = 5 , p 1 ′ = 0.5 , B i n o m i a l ( 5 , 0.5 ) = 2 , x 1 = 2 i = 1,n_1' = 5,p_1' = 0.5, Binomial(5, 0.5) = 2, x_1 = 2 i=1,n1′=5,p1′=0.5,Binomial(5,0.5)=2,x1=2
- i = 2 , n 2 ′ = 3 , p 2 ′ = 0.3 / ( 0.3 + 0.2 ) = 0.6 , B i n o m i a l ( 3 , 0.6 ) = 2 , x 2 = 2 i = 2, n_2' = 3,p_2' = 0.3/(0.3+0.2) = 0.6, Binomial(3, 0.6) = 2, x_2 = 2 i=2,n2′=3,p2′=0.3/(0.3+0.2)=0.6,Binomial(3,0.6)=2,x2=2
- i = 3 , n 3 ′ = 1 , p 3 ′ = 0.2 / 0.2 = 1.0 , B i n o m i a l ( 1 , 1.0 ) = 1 , x 3 = 1 i = 3, n_3' = 1, p_3' = 0.2/0.2 = 1.0, Binomial(1, 1.0) = 1, x_3 = 1 i=3,n3′=1,p3′=0.2/0.2=1.0,Binomial(1,1.0)=1,x3=1
- ( x 1 = 2 , x 2 = 2 , x 3 = 1 ) (x_1 = 2, x_2 = 2, x_3 = 1) (x1=2,x2=2,x3=1)
模拟生成多项式变量
import numpy as np
import matplotlib.pyplot as plt
def generateMultinomial(n = 100, k=3, probas=[0.5, 0.3, 0.2]):
x = [0, 0, 0]
for i in range(k):
p_ = probas[i]/np.sum(probas[i:])
n_ = n - np.sum(x[:i+1])
b = np.random.binomial(n_, p_)
x[i] = b
return x

边栏推荐
- 【Try to Hack】vulnhub DC2
- Chapter 7 deformation operation of canvas
- 《canvas》之第13章 事件操作
- Draw a slash on a plane coordinate
- You need to know about project procurement management
- [practical chapter of correlation analysis] why can't Bi software do correlation analysis
- 华理生物冲刺科创板:年营收2.26亿 拟募资8亿
- Nuscenes configuration information about radar
- Whitelabel error page access
- Configuration tutorial for swagger2
猜你喜欢

阿里云体验有奖:使用PolarDB-X与Flink搭建实时数据大屏

威高血液净化冲刺香港:年营收29亿 净利降12.7%

Slow bear market, bit Store provides stable stacking products to help you cross the bull and bear

网易严选离线数仓质量建设实践

June 27 talk SofiE

You need to know about project procurement management

华曙高科冲刺科创板:拟募资6.6亿 实控人许小曙父子均为美国籍

Explanation on deployment and establishment of decentraland process

Query function of Excel vlookup

Chapter 12 other applications of canvas
随机推荐
kubernetes Unable to connect to the server: x509: certificate has expired or is not yet valid
华曙高科冲刺科创板:拟募资6.6亿 实控人许小曙父子均为美国籍
三角函数对应在平面坐标上画圆
Practical application cases of drives
Campus errands wechat applet errands students with live new source code
How bad can a programmer be?
Chapter 7 deformation operation of canvas
《canvas》之第7章 变形操作
在平面坐标上画斜线
《canvas》之第6章 图片操作
《canvas》之第14章 物理动画
Asynchronous artifact completable future
【关联分析实战篇】为什么 BI 软件都搞不定关联分析
捷氢科技冲刺科创板:拟募资10.6亿 上汽集团是大股东
k8s部署redis哨兵
阿里云体验有奖:使用PolarDB-X与Flink搭建实时数据大屏
校园转转二手市场源码
Stm32 mbed tutorial (IV) --pwm
Netease strict selection offline data warehouse quality construction practice
期货开户可以线下开户吗?在网上开户安全吗?