0
$\begingroup$

This is very basic, but I just want certainty that what I'm doing isn't stupid.

Say I have a set of data which gives me a probability of an event A happening each day for a week.

For example:

day 1: 0.1
day 2: 0.15
day 3: 0.05
day 4: 0.1
day 5: 0.1
day 6: 0.05
day 7: 0.05

Now, what I want is the number of event A we expect to have happened after these 7 days.

What I would do, considering this binomial distribution, is:

E = 0.1 + 0.15 + 0.05 + 0.1 + 0.1 + 0.05 + 0.05 = 0.6

Hence, we expect 0.6 event A to happen during that week.

Is this correct?

As an aside, I'll then want to apply a Poisson process on this to obtain the probability of the event A happening within the next year, that is P(t < 1y) = 1 - exp(-0.6/7 * 365)

$\endgroup$
0
$\begingroup$

You are right.
The expected value of A event in a week is: $$ E[X] = 1 \cdot 0.1 + 1 \cdot 0.15 + 1 \cdot 0.05 + 1 \cdot 0.1 + 1 \cdot 0.1 +1 \cdot 0.05 + 1 \cdot 0.05 = 0.6 $$

And when k is the number of A events happen, the Poisson distirbution probability is: $$ p( k ; \lambda) = e^{-\lambda} \frac{\lambda^k}{k!} $$ $$ \text{where } \lambda = \frac{events}{time}*period$$

Then, the probability of the event A happening in next 365/7 weeks is equal to 1 minus the probability of the event A not happening at all: $$ 1- P(k=0; \lambda) = 1 - e^{-0.6 * 365/7} \frac{\lambda^0}{0!} $$

which is almost 1.

$\endgroup$
0
$\begingroup$

Hmmm, so, I decided to test it out in python:

import numpy as np
rows = [(1, 0.1), (2, 0.15), (3, 0.05), (4, 0.1), (5, 0.1), (6, 0.05), (7, 0.05)]

scenario = 0
n=50000
elts, probs = np.array(rows).T
m = len(elts)
scenario = [elts[np.random.rand(m) < probs].astype(int) for _ in range(n)]

print(np.mean([len(i) for i in scenario]))

This gives me when I run it 10 times:

0.60118
0.59308
0.60536
0.59812
0.6013
0.59246
0.6025
0.6027
0.60146
0.59656
0.59716

Hence it should confirm empirically that what I believed was indeed correct.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.