I am writing an application which will monitor stock prices and alert the user of abnormally large price changes. Given a set of previous price changes (fitting into a bell curve) and a new observation, I would like to figure out what portion of the bell curve the observed value is above.

So I have my set of historical values

$$H = \{c_1, c_2,\ ...\ , c_n\}$$

and a new observation $c_{obs}$

How do I work out the percentage of the bell curve the $c_{obs}$ is greater than?

Additional question:

Given a new incoming value, I would like to add it to the historical values. Is there a technique for adjusting the necessary values for this calculation like there is for the mean?

ie. For the mean, if you know the previous mean and the number of values you can adjust for the new mean like so

$$mean_{new} = \frac{mean_{old} * n + c_{obs}}{n + 1}$$

where $n$ is the number of values and $c_{obs}$ is the new value.

  • $\begingroup$ Not sure if the assumption of normally distributed returns is so accurate. I suspect the distribution is very asymmetric (i.e., more positive returns in booms, more negative values in recessions), so whenever you compute percentiles based on z-scores you may be wrong. $\endgroup$
    – Nameless
    Commented Dec 3, 2013 at 11:49

1 Answer 1


To answer your question as stated: You can estimate the percentile of a particular observed price by entering each stock price into the following formula $\Phi(\frac{c_{obs}-\bar x_{old}}{s_{old}})$, which just evaluates the price given the current best estimate of the past behavior. You can also form a prediction confidence distribution then see the probability that you would have predicted a deviation at least as large as what you observe.

Of course, all this is predicated on the validity of the normal distribuiton for stock returns. A lognormal would be qualitatively more accurate, assuming the percentage gain/loss is lognormally distributed. Also, you are assuming the past behavior is representative of future behavior -- a well-known caveat in most investing prospectuses is that this cannot be relied on. However, for the sake of argument, you may want to take a non-parametric approach:

For example you could set up a hypothesis test with $H_0:P(X\leq c_{obs}) \leq \alpha$ and $H_a: P(X\leq c_{obs}) > \alpha$, where $\alpha$ is your target percentile for identifying "outliers" at the upper end. You can then use the sign test with $p=\alpha$ to determine if it passes your test at a given significance (e.g., .01, .001) depending on your risk tolerance. The same thing can be done with a lower bound by reversing the inequalities between the percentile and $\alpha$ and testing a lower percentile.

  • $\begingroup$ It's not so much for prediction as it is to go "whoa that was big". The log normal distribution looks more accurate than a normal distribution you're right. Could you explain that $\Phi$ formula to me? Looks to me like it's just giving the number of standard deviations from the mean? Also, having given it some more thought, I think I can simply count number of price changes below and divide by the total number to get an estimate of percentile. Since that's kind of the definition of a discrete distribution. It will start inaccurate but get more accurate. I can just give it old data to start. $\endgroup$ Commented Dec 4, 2013 at 3:29
  • $\begingroup$ @null0pointer I suggested the prediction distribution not for predcition, per se, but for restrospective assessment of what would have been expected for your current data point given the past data points - the logic being that if your current data point would not have represented a reasonable prediction given the previous data, then it is possibly an outlier or unusual value. Your empirical approach to generating percentiles is fine, although you may want to use $\frac{n+1}{N+2}$ to get a more robust estimate, especially for low sample sizes. Also, give some thought to the "data horizon" $\endgroup$
    – user76844
    Commented Dec 4, 2013 at 13:38
  • $\begingroup$ (cont'd) in other words, how much of the past do you want to use to define "typical". Obviously, after some time, its hard to maintain that the entire price history is relevant. Since you're considering a non-parametric approach (which I agree with), i won't discuss the $\Phi$ formula, as it applied to normal distributions. Consider the hypothesis test I gave you as a simple way to have a computer flag unusually large values as they arise. $\endgroup$
    – user76844
    Commented Dec 4, 2013 at 13:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .