Meinfelder, Florian
2014-Feb-18 22:08 UTC
[R] calculate probability of union of independent events
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 ___________________________________________________ Dr. Florian Meinfelder Otto-Friedrich-Universität Bamberg Lehrstuhl für Statistik und Ökonometrie Feldkirchenstraße 21, D-96052 Bamberg Telefon: +49 (0)951/863-2741 Fax: +49 (0)951/863-2532 email: florian.meinfelder@uni-bamberg.de<mailto:florian.meinfelder@uni-bamberg.de> www: http://www.uni-bamberg.de/stat-oek/ [[alternative HTML version deleted]]
(Ted Harding)
2014-Feb-18 23:51 UTC
[R] calculate probability of union of independent events
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, > FlorianI 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