For an event that occurs with probability p, this function returns the probability of an occurrence given n repetitions. p is numeric and can be a vector.

probability_any(n, p)

Arguments

n

The number of times to repeat the event (independent)

p

The individual probability of the event happening

Value

The probability of an event with the specified probability, after n repetitions

Details

The probability that any event p occurs with n repetitions is equal to the reciprocal of the probability that p never occurs. The probability that p never occurs with n repetitions is (1 - p) ^ n. Thus, the probability that any event p occurs after n repetitions is 1 - ( (1 - p) ^ n ).

Examples

probability_any(1, 0.5)
#> [1] 0.5
probability_any(2, 0.5)
#> [1] 0.75
probability_any(2, c(0.5, 1/3, 0.25))
#> [1] 0.7500000 0.5555556 0.4375000