当前位置:网站首页>MCS: multivariate random variable - discrete random variable
MCS: multivariate random variable - discrete random variable
2022-06-29 15:13:00 【Fight the tiger tonight】
Multivariate Discrete Arbitrary
Yes k k k A discrete random variable : ( x 1 , . . . , x k ) (x_1, ...,x_k) (x1,...,xk), The joint probability distribution is : P ( x 1 , . . . , x k ) P(x_1, ...,x_k) P(x1,...,xk), k k k The probability sum of all possible values of variables is :1.
∑ x 1 ∼ x k P ( x 1 . . . x k ) = 1.0 \sum_{x_1 \sim x_k} P(x_1...x_k) = 1.0 x1∼xk∑P(x1...xk)=1.0
Marginal probability , k k k One of the variables , Write it down as : x j x_j xj
P ( x j . . . ) = ∑ a l l x b u t x j P ( x 1 , x 2 , . . . , x k ) P(x_j...) = \sum_{all_x but_{x_j}} P(x_1, x_2, ...,x_k) P(xj...)=allxbutxj∑P(x1,x2,...,xk)
Marginal expectation :
E ( x j . . . ) = ∑ x j x j P ( x j . . . ) E(x_j...) = \sum_{x_j} x_j P(x_j...) E(xj...)=xj∑xjP(xj...)
marginal Variance :
V ( x j . . . ) = E ( x j 2 . . . ) − E ( x j . . . ) 2 V(x_j...) = E(x_j^2...) - E(x_j...)^2 V(xj...)=E(xj2...)−E(xj...)2
E ( x j 2 . . . ) = ∑ x j x j 2 P ( x j . . . ) E(x_j^2...) = \sum_{x_j} x_j^2 P(x_j...) E(xj2...)=xj∑xj2P(xj...)
Generating random variables
Generate k k k A random variable of discrete variables : ( x 1 , x 2 , . . . , x k ) (x_1, x_2, ...,x_k) (x1,x2,...,xk)
- obtain x 1 x_1 x1 Marginal probability and cumulative distribution : P ( x 1 . . . ) 、 F ( x 1 . . . ) P(x_1...)、F(x_1...) P(x1...)、F(x1...)
- Generate a random continuous uniform variable : u ∼ U ( 0 , 1 ) u \sim U(0, 1) u∼U(0,1)
- Find a random variable larger than u u u Of F ( x 1 . . . ) F(x_1...) F(x1...) Corresponding x 1 x_1 x1 The minimum value of , Write it down as : x 10 x_{10} x10
- obtain x 2 x_2 x2 Marginal conditional probability and cumulative distribution : P ( x 2 ∣ x 10 . . . ) 、 F ( x 2 ∣ x 10 . . . ) P(x_2|x_{10}...)、F(x_2|x_{10}...) P(x2∣x10...)、F(x2∣x10...)
- Generate a random continuous uniform variable : u ∼ U ( 0 , 1 ) u \sim U(0, 1) u∼U(0,1)
- Find a random variable larger than u u u Of F ( x 2 ∣ x 10 . . . ) F(x_2|x_{10}...) F(x2∣x10...) Corresponding x 2 x_2 x2 The minimum value of , Write it down as : x 20 x_{20} x20
- obtain x 3 x_3 x3 Marginal conditional probability and cumulative distribution : P ( x 3 ∣ x 10 x 20 . . . ) 、 F ( x 3 ∣ x 10 x 20 . . . ) P(x_3|x_{10}x_{20}...)、F(x_3|x_{10}x_{20}...) P(x3∣x10x20...)、F(x3∣x10x20...)
- Generate a random continuous uniform variable : u ∼ U ( 0 , 1 ) u \sim U(0, 1) u∼U(0,1)
- Find a random variable larger than u u u Of F ( x 3 ∣ x 10 x 2 0 . . . ) F(x_3|x_{10}{x_20}...) F(x3∣x10x20...) Corresponding x 3 x_3 x3 The minimum value of , Write it down as : x 30 x_{30} x30
- Repeat until you get : x k 0 x_{k0} xk0
- ( x 1 0 , . . . x k 0 ) (x_10, ... x_{k0}) (x10,...xk0)
example : Suppose a multivariate discrete random variable : ( x 1 , x 2 , x 3 ) (x_1, x_2, x_3) (x1,x2,x3), x 1 x_1 x1 Possible values are : { 0 , 1 , 2 } \{0,1,2\} { 0,1,2}, x 2 x_2 x2 Possible values are : { 0 , 1 } \{0, 1\} { 0,1}, x 3 x_3 x3 Possible values are : { 1 , 2 , 3 } \{1,2,3\} { 1,2,3}, The probability distribution is as follows :
P ( x 1 , x 2 , x 3 ) P(x_1, x_2, x_3) P(x1,x2,x3)
| x 3 x_3 x3 | 1 | 2 | 3 | 1 | 2 | 3 |
|---|---|---|---|---|---|---|
| x 2 x_2 x2 | 0 | 1 | ||||
| x 1 x_1 x1 | ||||||
| 0 | 0.12 | 0.10 | 0.08 | 0.08 | 0.06 | 0.05 |
| 1 | 0.08 | 0.06 | 0.04 | 0.05 | 0.04 | 0.03 |
| 2 | 0.06 | 0.04 | 0.02 | 0.04 | 0.03 | 0.02 |
Generate multivariate discrete random variables according to probability distribution :
- x 1 x_1 x1 Marginal probability and cumulative distribution :
- P ( x 1 = 0... ) = 0.12 + 0.10 + 0.08 + 0.08 + 0.06 + 0.05 = 0.49 、 F ( 0... ) = 0.49 P(x_1 = 0...) = 0.12 + 0.10 + 0.08 + 0.08 + 0.06 + 0.05 = 0.49、F(0...) = 0.49 P(x1=0...)=0.12+0.10+0.08+0.08+0.06+0.05=0.49、F(0...)=0.49
- P ( x 1 = 1... ) = 0.08 + 0.06 + 0.04 + 0.05 + 0.04 + 0.03 = 0.30 、 F ( 1... ) = 0.79 P(x_1 = 1...) = 0.08 + 0.06 + 0.04 + 0.05 + 0.04 + 0.03 = 0.30、F(1...) = 0.79 P(x1=1...)=0.08+0.06+0.04+0.05+0.04+0.03=0.30、F(1...)=0.79
- P ( x 1 = 2... ) = 0.06 + 0.04 + 0.02 + 0.04 + 0.03 + 0.02 = 0.21 、 F ( 2... ) = 1.00 P(x_1 = 2...) = 0.06 + 0.04 + 0.02 + 0.04 + 0.03 + 0.02 = 0.21、F(2...) = 1.00 P(x1=2...)=0.06+0.04+0.02+0.04+0.03+0.02=0.21、F(2...)=1.00
- u ∼ U ( 0 , 1 ) , u = 0.37 , u < F ( 0 ) u \sim U(0, 1),u = 0.37,u < F(0) u∼U(0,1),u=0.37,u<F(0) Make : x 10 = 0 x_{10} = 0 x10=0
- x 2 x_2 x2 Of ( Conditions ) Marginal probability and cumulative distribution :
- P ( x 2 = 0 ∣ x 10 = 0... ) = ( 0.12 + 0.10 + 0.08 ) / 0.49 = 0.612 、 F ( 0 ∣ 0... ) = 0.612 P(x_2 = 0|x_{10} = 0...) = (0.12 + 0.10 + 0.08)/0.49 = 0.612、F(0|0...) = 0.612 P(x2=0∣x10=0...)=(0.12+0.10+0.08)/0.49=0.612、F(0∣0...)=0.612
- P ( x 2 = 1 ∣ x 10 = 0... ) = ( 0.08 + 0.06 + 0.05 ) / 0.49 = 0.388 、 F ( 1 ∣ 0... ) = 1.000 P(x_2 = 1|x_{10} = 0...) = (0.08 + 0.06 + 0.05)/0.49 = 0.388、F(1|0...) = 1.000 P(x2=1∣x10=0...)=(0.08+0.06+0.05)/0.49=0.388、F(1∣0...)=1.000
- u ∼ U ( 0 , 1 ) , u = 0.65 , u < F ( 1 ∣ 0... ) u \sim U(0, 1),u = 0.65,u < F(1|0...) u∼U(0,1),u=0.65,u<F(1∣0...) Make : x 20 = 1 x_{20} = 1 x20=1
- x 3 x_3 x3 Of ( Conditions ) Marginal probability and cumulative distribution :
- P ( x 3 = 1 ∣ x 10 x 20 . . . ) = 0.08 / 0.19 = 0.421 、 F ( 1 ∣ 0 , 1... ) = 0.421 P(x_3 = 1|x_{10}x_{20}...) = 0.08/0.19 = 0.421、F(1|0,1...) = 0.421 P(x3=1∣x10x20...)=0.08/0.19=0.421、F(1∣0,1...)=0.421
- P ( x 3 = 2 ∣ x 10 x 20 . . . ) = 0.06 / 0.19 = 0.316 、 F ( 2 ∣ 0 , 1... ) = 0.737 P(x_3 = 2|x_{10}x_{20}...) = 0.06/0.19 = 0.316、F(2|0,1...) = 0.737 P(x3=2∣x10x20...)=0.06/0.19=0.316、F(2∣0,1...)=0.737
- P ( x 3 = 3 ∣ x 10 x 20 . . . ) = 0.05 / 0.19 = 0.263 、 F ( 3 ∣ 0 , 1... ) = 1.000 P(x_3 = 3|x_{10}x_{20}...) = 0.05/0.19 = 0.263、F(3|0,1...) = 1.000 P(x3=3∣x10x20...)=0.05/0.19=0.263、F(3∣0,1...)=1.000
- u ∼ U ( 0 , 1 ) , u = 0.55 , u < F ( 1 ∣ 0 , 1... ) u \sim U(0, 1),u = 0.55,u < F(1|0,1...) u∼U(0,1),u=0.55,u<F(1∣0,1...) Make : x 30 = 2 x_{30} = 2 x30=2
- ( x 10 , x 20 , x 30 ) = ( 0 , 1 , 2 ) (x_{10},x_{20},x_{30}) = (0, 1, 2) (x10,x20,x30)=(0,1,2)
Simulation generates multivariate random variables
import numpy as np
import matplotlib.pyplot as plt
def multivariateDiscrete(num=10):
x1, x2, x3 = [], [], []
for i in range(10000):
u = np.random.uniform(0, 1)
temp = []
for k, v in {
0:0.49,1:0.79,2:1.0}.items():
if v > u:
temp.append(k)
x1.append(np.min(temp))
u = np.random.uniform(0, 1)
temp = []
for k, v in {
0: 0.612, 1:1.0}.items():
if v > u:
temp.append(k)
x2.append(np.min(temp))
u = np.random.uniform(0, 1)
temp = []
for k, v in {
1:0.412, 2:0.737, 3:1.00}.items():
if v > u:
temp.append(k)
x3.append(np.min(temp))
return x1, x2, x3

边栏推荐
- Implementing redis distributed locks using custom annotations
- JS will have variable promotion and function promotion
- 信息学奥赛一本通1194:移动路线
- Const usage
- Lumiprobe deoxyribonucleic acid alkyne DT phosphimide
- 信息学奥赛一本通2061:梯形面积
- Informatics Olympiad 1001:hello, world!
- Lumiprobe 点击化学丨非荧光炔烃:己酸STP酯
- nfs配置两台主机之间的文件映射
- 打造一个 API 快速开发平台,牛逼!
猜你喜欢

Hi, you have a code review strategy to check

What is the relationship between synchronized and multithreading

重磅!2022最新SCI影响因子发布,三大名刊NCS及国内期刊TOP10排名有变化 (内附2022年最新影响因子)

又拍云 Redis 的改进之路

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

Ink drop typesetting

How does a two character name become a three character name with spaces

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

Lumiprobe reactive dye cycloalkyne dye: af488 dbco, 5 isomer

Hi,你有一份Code Review攻略待查收
随机推荐
Northwestern Polytechnic University attacked by overseas e-mail
真正的软件测试人员 =“半个产品+半个开发”?
Evaluation index of high concurrency software (website, server interface)
PyTorch 二维多通道卷积运算方式
nfs配置两台主机之间的文件映射
知识点:PCB线路板布线都有哪些诀窍?
BioVendor游离轻链(κ和λ)Elisa 试剂盒的化学性质
目前股票开户安全吗?可以直接网上开户吗
他山之石 | 丁香园 医疗领域图谱的构建与应用
I log in to the RDB database and prompt that the master account authorization is required. How do I know who to call?
message from server: “Host ‘xxxxxx‘ is blocked because of many connection errors; unblock with ‘m
Indice d'évaluation du logiciel hautement simultané (site Web, interface côté serveur)
MCS:离散随机变量——Pascal分布
威高血液净化冲刺香港:年营收29亿 净利降12.7%
Biovendor free light chain( κ and λ) Chemical properties of ELISA Kit
MCS:多元随机变量——离散随机变量
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
Ink drop typesetting
kubernetes Unable to connect to the server: x509: certificate has expired or is not yet valid
Is it reliable to invest in REITs funds? Is REITs funds safe