• MCS:离散随机变量——Pascal分布


    Pascal

    帕斯卡分布,负二项分布的正整数形式。当变量 x x x表示某项实验获得 k k k次成功时,实验重复的次数,变量 x x x服从帕斯卡分布,实验成功概率为: p p p

    P ( x ) = C k − 1 x − 1 p k ( 1 − p ) x − k , x = k , k + 1 , . . . P(x) = C_{k-1}^{x - 1} p^k(1 - p)^{x - k},x = k, k+1, ... P(x)=Ck1x1pk(1p)xkx=k,k+1,...

    F ( x ) = ∑ y = k x P ( y ) , x = k , k + 1 , . . . F(x) = \sum_{y=k}^x P(y),x = k, k+1, ... F(x)=y=kxP(y)x=k,k+1,...

    期望和方差:

    E ( x ) = k p E(x) = \frac{k}{p} E(x)=pk

    V ( x ) = k ( 1 − p ) p 2 V(x) = \frac{k(1 - p)}{p^2} V(x)=p2k(1p)

    当变量 x ′ x' x定义为获得 k k k次成功时,失败的次数, x ′ = x − k x' = x - k x=xk

    • E ( x ′ ) = E ( x ) − k = k ( 1 − p ) / p E(x') = E(x) - k = k(1 - p)/p E(x)=E(x)k=k(1p)/p
    • V ( x ′ ) = V ( x ) = k ( 1 − p ) / p 2 V(x') = V(x) = k(1 - p)/p^2 V(x)=V(x)=k(1p)/p2

    生成Pascal变量: x x x

    1. x = 0 x = 0 x=0
    2. For i = 1 → k i = 1 \to k i=1k:
      • 生成随机几何变量 y = G ( p ) y = G(p) y=G(p):第一次成功时实验的次数
      • x = x + y x = x + y x=x+y
      • i = i + 1 i = i + 1 i=i+1
    3. Return x x x

    例:变量 x x x为帕斯卡变量, p = 0.5 , k = 5 p = 0.5,k = 5 p=0.5k=5 x x x表示为获得第5次成功时,实验重复的次数,生成变量 x x x

    1. x = 0 x = 0 x=0
    2. i = 1 , y = G ( 0.5 ) = 3 , x = 3 i = 1,y = G(0.5) = 3,x = 3 i=1y=G(0.5)=3x=3
    3. i = 2 , y = G ( 0.5 ) = 1 , x = 4 i = 2,y = G(0.5) = 1,x = 4 i=2y=G(0.5)=1x=4
    4. i = 3 , y = G ( 0.5 ) = 2 , x = 6 i = 3,y = G(0.5) = 2,x = 6 i=3y=G(0.5)=2x=6
    5. i = 4 , y = G ( 0.5 ) = 4 , x = 10 i = 4,y = G(0.5) = 4,x = 10 i=4y=G(0.5)=4x=10
    6. i = 5 , y = G ( 0.5 ) = 2 , x = 12 i = 5,y = G(0.5) = 2,x = 12 i=5y=G(0.5)=2x=12
    7. x = 12 x = 12 x=12

    模拟生成Pascal变量

    import numpy as np
    import matplotlib.pyplot as plt
    
    • 1
    • 2
    def generate_pascal(k=5, p=0.1):
        x = np.sum(np.random.geometric(p=p, size=(k)))
        return x
    
    • 1
    • 2
    • 3

    在这里插入图片描述

  • 相关阅读:
    取消excel表格中的隐藏行
    获取需要对比的日期范围方法
    Vue.js 循环语句
    算法题练习——NC93 设计LRU缓存结构
    芯片洁净间的等级是如何划分的
    Windows与网络基础-27-子网掩码
    Docker部署Redis内存数据库
    猜名次(附完整代码)
    hive补全连续或非连续空值数据sql
    设计模式---建造者模式
  • 原文地址:https://blog.csdn.net/u014281392/article/details/125474865