# Probability of independent events within a specified window

So I have an event that can occur on a daily basis with probabilty 1%. There is no dependence between days. Now I can calculate the probabality of the event occuring X times in Y days:

  COMBIN(Y,X) * (0.01 ^ X) * [0.99 ^ (Y - X)]


where COMBIN() is the number of combinations for X in Y. Now what I'd like to calculate is the probablity of X events in any Y window for the last Z days, e.g what is the probability of 5 events occuring in at least one 30 day window during the last 10 years. Any assistance much appreciated.

Thanks

Note: Original question edited to add "at least" qualifier per MansT suggestion below.

-
If this is homework, it should have the homework tag. – Peter Flom Oct 1 '12 at 21:50
Not homework, real world problem cast in generalised terms... my stats is a bit rusty – Richard H Oct 3 '12 at 7:53
Do you mean "the probability of 5 events in at least one 30 day window for the last 10 years"? – MånsT Oct 10 '12 at 12:15
@MånsT - yes exactly – Richard H Oct 10 '12 at 12:23
Analytical answers are preferable, but given its not homework, I am curious why you don't use brute force Monte Carlo simulation. – phaneron Oct 12 '12 at 17:00
show 1 more comment

If the days are truly independent as you say then let us denote an event A as X events in any Y day period and denote P(A), the probability of X events in Y days:

P(A) = COMBIN(Y,X) * (0.01 ^ X) * [0.99 ^ (Y - X)]

This is true for any Y day window provided the probability of an event occurring is not time dependent.

Then you can apply the Binomial probability again to the event A. We have to be careful because now the event A is not independent for overlapping windows, i.e. for a window of length 10, the probability of event A on days 1-10 is not independent of days 2-11. Thus the following is assuming non-overlapping windows to ensure independence. Now, because you want the probability of at least one non-overlapping window having an event, it is easier to do:

1 - P(no overlapping windows satisfying event A).

Let n be the number of non-overlapping windows of size Y in time period Z. Then the probability of X events in a non-overlapping window of size Y over a time period Z is:

1 - COMBIN(n,0) * P(A)^0 * [1-P(A)]^(Y-0)

= 1 - n * [1-P(A)]^Y

-
 thanks for your answer; I am examining and will revert. – Richard H Oct 10 '12 at 14:41 This would answer the question if it were about months and not windows. I believe that a window is defined as 30 consecutive days (correct me if I'm wrong, @Richard). January 1-30 is a window, but so is January 2-31. The windows are not independent in that case. Indeed, window $i+1$ can only have $X$ events if window $i$ has at least $X-1$ events. – MånsT Oct 10 '12 at 16:24 MansT is correct, there is an implied assumption that the windows are independent. I've edited my response to make it clear that the solution is for non-overlapping windows. – adunaic Oct 12 '12 at 8:35 @aduniac - yes I am looking for a solution for over-lapping windows, not adjacent non-overlapping windows. – Richard H Oct 18 '12 at 8:20 @MansT - your understanding of the problem is correct: probability of X number of events in any 30 day window in the last 10 years. – Richard H Oct 18 '12 at 8:22