Message-ID: <XFMail.20140218235133.Ted.Harding@wlandres.net>
Date: 2014-02-18T23:51:33Z
From: (Ted Harding)
Subject: calculate probability of union of independent events
In-Reply-To: <7D6153F2E0FA4145A22FA82E97C211D701111A15@exmbx01.UNI-BAMBERG.DE>
On 18-Feb-2014 22:08:38 Meinfelder, Florian wrote:
> Dear all,
>
> I am looking for a way to calculate the probability of the union of k
> independent events in R. Is there a function that takes a k-dimensional
> probability vector as input and returns p(A_1 U A_2 U...U A_k)?
>
> Thanks,
> Florian
I don't know (off-hand); but it is very easy to write one's own!
Since
P(A1 U A2 U ... U Ak )
= 1 - P(not(A1 U A2 U ... u Ak))
= 1 - P((not A1) & (not A2) & ... & (not Ak))
= 1 - P(not A1)*P(not A2)* ... *P(not Ak) [by independence]
= 1 - (1-p1)*(1-p2)* ... *(1-pk)
where pj is P(Aj). Hence
punion <- function(p){1 - prod(1-p)}
should do it!
Ted.
-------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at wlandres.net>
Date: 18-Feb-2014 Time: 23:51:31
This message was sent by XFMail