如何确定 0 到 N 事件发生的概率,给定这 N 个事件中的每一个的概率?

How to determine probability of 0 to N events occurring given probability of each of those N events?

第一次在这里发帖,所以如果我在某些地方犯了错误,请告诉我,我会非常乐意修正它!

给定 N 个事件,每个事件都有单独的发生概率(从 0 到 100%),我想确定这些事件一起发生的概率为 0 到 N。

例如,如果我有事件 1、2、3、...、N 和 5(E1、E2、E3...、EN),其中特定事件发生的个体概率如下:

我想知道拥有的概率:

我知道发生 0 个事件是 (1-E1)(1-E2)...(1-EN) 并且发生所有 N 个事件是 E1*E2*...*E3。但是,我不知道如何计算其他可能性(发生1到N-1个事件)。

我一直在寻找一些可以解决这个问题的递归算法(二项式复合分布),但我还没有找到任何明确的公式来解决这个问题。想知道你们中的任何人是否可以提供帮助!

提前致谢!

编辑:事件确实独立

您需要计算您自己的帕斯卡三角形版本,每个位置的概率(而不是计数)。第 0 行将是单个数字 1.00;第 1 行包含两个值,P(E1) 和 1-P(E1)。在此之下,在第 k 行中,每个位置是 P(Ek)[右上条目] + (1-P(Ek))[左上条目]。我为此推荐一个下三角矩阵,例如:

1.00
0.30 0.70
0.12 0.46 0.42  # These are 0.3*0.4 | 0.3*0.6 + 0.7*0.4 | 0.7*0.6
0.06 0.29 0.44 0.21  # 0.12*0.5 | 0.12*0.5 + 0.46*0.5 | ...

看看它是如何工作的?在矩阵 M 的数组/矩阵符号中,给定向量 P 中的事件概率,这看起来像

M[k, i] = P[k] * M[k-1, i] +
          (1-P[k]) * M[k-1, i] + P[k] * M[k-1, i-1]

以上是一个很好的递归定义。请注意,我之前在下矩阵表示法中的 "above-right" 引用只是上面的一行; above-left 正是:第 k-1 行,第 i-1 列。

完成后,矩阵的底行将是获得 N, N-1, N-2, ... 0 个事件的概率。如果你想要这些概率的顺序相反,那么只需切换系数 P[k] 和 1-P[k]

这是否促使您找到解决方案?

听起来像泊松二项式 wikipedia link.

有明确的递归公式,但要注意数值稳定性。

哪里

类似于以下递归程序的东西应该可以工作。

function ans = probability_vector(probabilities)
    if len(probabilities) == 0
        % No events can happen.
        ans = [1];
    elseif len(probabilities) == 1
        % 0 or 1 events can happen.
        ans = [1 - probabilities[1], probabilities[1]];
    else
        half = ceil(len(probabilities)/2);
        ans_half1 = probability_vector(probabilities[1: half]);
        ans_half2 = probability_vector(probabilities[half + 1: end]);
        ans = convolve(ans_half1, ans_half2)
    end
    return
end

如果p是一个概率向量,那么p[i+1]就是事件发生i的概率。

请参阅 http://matlabtricks.com/post-3/the-basics-of-convolution 以了解对完成工作的魔术 conv 运算符的解释。

经过大量研究和此处答案的一些帮助,我想出了以下代码:

function [ prob_numSites ] = probability_activationSite( prob_distribution_site )

N = length(prob_distribution_site); % number of events
notProb = 1 - prob_distribution_site; % find probability of no occurrence
syms x; % create symbolic variable
prob_number = 1; % initializing prob_number to 1

for i = 1:N
    prob_number = prob_number*(prob_distribution_site(i)*x + notProb(i));
end

prob_number_polynomial = expand(prob_number); % expands the function into a polynomial
revProb_numSites = coeffs(prob_number_polynomial); % returns the coefficients of the above polynomial (ie probability of 0 to N events, where first coefficient is N events occurring, last coefficient is 0 events occurring)
prob_numSites = fliplr(revProb_numSites); % reverses order of coefficients

这需要一定数量的单个事件发生的概率和 returns 0 到 N 事件发生概率的数组。

This 回答帮了大忙)。

None 这些答案对我来说似乎 worked/was 可以理解,所以我计算了它并在 python 中自己做了:


def combin(n, k):
   if k > n//2:
       k = n-k
   x = 1
   y = 1
   i = n-k+1
   while i <= n:
       x = (x*i)//y
       y += 1
       i += 1
   return x

# proba being the probability of each of the N evenments, each being different from one another.

for i in range(N,0,-1):
    print(i)
    if sums[i]> 0:
        continue
    print(combin(N,i))
    for j in itertools.combinations(proba, i):
        sums[i]+=np.prod(j) 
for i in range(N,0,-1):
    for j in range(i+1,N+1):
        icomb = combin(j,i)
        sums[str(i)] -= icomb*sums[str(j)]

数学不是很简单:

设$C_{w_n}$为所有无序集合$(i,j,k...n)$

其中 $i,j,k...n\in w$

$Co(i,proba) = sum{C_{w_i}} - sum_{u from i+1..n}{(u \choose i)总和{C_{w_u}}}$*

$Co(i, P)$ 是给定 $P = {p_i...p_n}$ 时 i 事件发生的概率,伯努利概率每个事件。