【问题标题】:How to get distribution of sum of dependent bernoulli variables如何获得因伯努利变量之和的分布
【发布时间】:2014-02-05 15:55:25
【问题描述】:

我有 N 个伯努利变量,X1, ..., XN, 和 Xi~B(1, pi), pi 对于每个 XiY=X1+...XN 都是已知的,现在我需要得到分布Y.

如果XiXji!=j时是独立的,那么我可以使用模拟:

1. Generate `X1`, ..., `XN` via their distribution, and then get the value of `Y`;
2. Repet step 1 for 10000 times, and then I can get `Y1`, ..., `Y10000`, so I can konw the distribution of `Y`.

但是现在XiXj是有依赖关系的,所以我还需要考虑相关性,假设corr(Xi, Xj)=0.2i!=j时,如何将相关性插入到模拟中?或者通过其他方式得到Y的分布?

感谢您的帮助和建议。

【问题讨论】:

    标签: distribution multinomial bernoulli-probability


    【解决方案1】:

    您可以通过推导一个给定另一个的条件分布来生成特定的成对相关性(在限制范围内)。限制是您不能拥有完全任意的 p 值和相关性。然而,N-choose-2 成对相关性集合所隐含的同时约束对于任意选择 N、p 值和相关性是不可行的。

    以下 Ruby 实现显示了为获得一对 X 的指定 p 值和相关性的计算:

    # Control the run with command-line args.
    # If no args provided, default to test case of
    # p1 = 0.2, p2 = 0.8, rho = -0.5, sample size = 10
    p1 = (ARGV.shift || 0.2).to_f
    p2 = (ARGV.shift || 0.8).to_f
    rho = (ARGV.shift || -0.5).to_f
    n = (ARGV.shift || 10).to_i
    
    # Calculate conditional probabilities for p2 given p1 = 0, 1
    p2_given = [p2 - rho * Math::sqrt(p1 * p2 * (1.0 - p2) / (1.0 - p1)),
                p2 + rho * Math::sqrt((1.0 - p1) * p2 * (1.0 - p2) / p1)]
    
    printf "p2_given_1 = %8.5f, p2_given_0 = %8.5f\n", p2_given[1], p2_given[0]
    
    # Only proceed to actually generate values if the conditional
    # probabilities are between zero and one
    if p2_given.inject(true) {|m, e| m &= (e >= 0 && e <= 1)}
      n.times do
        x1 = (rand <= p1) ? 1 : 0
        x2 = (rand <= p2_given[x1]) ? 1 : 0
        printf "%d,%d\n", x1, x2
      end
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-16
      • 2020-08-09
      • 2012-03-16
      • 1970-01-01
      • 2017-06-10
      • 1970-01-01
      • 2020-06-07
      • 2011-05-23
      相关资源
      最近更新 更多