I'm using R and would like to calculate the probability of an event happening. I used the ecdf function on daily revenue (month-to-date).

I have a target and a daily number necessary to hit target and I want to calculate based upon historical performance, the probability of hitting target.

Say my g= ecdf(x). Would g(daily target)-g(median performance) give me the probability that I am looking for?


Define $f(x)$ as the ecdf of $x,$ that is, the probability of observing a value less than or equal to $x$. What you want is probably $1-f(\text{target})$, the probability of observing a value larger than the target. Note that this makes some strong assumptions, like that each day is an iid random variable. If there's some kind of seasonal or day-of-week effect, your model won't be a great representation of reality.

  • $\begingroup$ Good point on the seasonality, but atm I don't want to make it too complicated. So in my example, if I do 1- g(daily target)-g(median performance) I will get the number I want? The reason why I am doing this is to take into account where we are now in relation to where we need to go in order to hit target. What is the difference between what I am trying to calculate and what you are recommending? Thanks! $\endgroup$ – Hidden Markov Model Aug 18 '15 at 20:18
  • $\begingroup$ @HiddenMarkovModel It's not clear to me at all why you'd subtract f(median). For example, some values of your target and your median, this will give you a negative number, not a probability! I interpreted your question as "Before tomorrow happens, what's the probability of exceeding the target tomorrow?"; your question in this comment appears to be "It's noon right now and we have D dollars, whats' the probability we have $target by the end of the day?" $\endgroup$ – Reinstate Monica Aug 18 '15 at 21:12
  • $\begingroup$ Good point, actually let me clarify. The number needed to hit target is x dollars per day for the next 10 days. Thus, wouldn't the probability be [1-F(x)]^10 since each day is independent (assuming Independence)? So if 1-F(x) is 0.12, then this would mean 0.12^10? This probability seems reasonable I guess since [1-F(x)]^10 is essentially saying what is the probability of some rare event occurring every day for the next 10 days. One issue I have with my idea is that say we set 1-F(X)=0.99, then 0.99^10 is 0.90, but if say 1-F(x)=0.9 then 0.9^10 = 0.34. This seems weird. What am I doing wrong? $\endgroup$ – Hidden Markov Model Aug 19 '15 at 10:50

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.