# Thread: Z-Score to Percentile Formula?

1. ## Z-Score to Percentile Formula?

I am looking for a formula to convert a z-score into the percentile or confidence interval.

for example a z-score of 1 would give 68%, a z-score of 2 would give 95%

what is the formula/equation for this?

I do not want to use an online z-score to percentile calculator, and I do not want to use a table or graph. I want to use a formula to convert my z-score to a percentile.

2. ## Re: Z-Score to Percentile Formula?

To find the area A under the standard normal curve between two zscores symmetric about the mean, you can use:

$A=\sqrt{\frac{2}{\pi}}\int_0^z e^{-\frac{x^2}{2}}\,dx$

Note: this will require numeric integration to obtain an approximation.

You may also use Taylor polynomials to approximate this as well.

3. ## Re: Z-Score to Percentile Formula?

G-day MarkFL2, cheers for putting up this equation, I've been scouring the web for hours looking for this. I was wondering if you might be able to clarify it a bit, I attempting to use the standard deviation and mean from some data to classify the probability (as a %) that a new value belongs to that data, i can calculate the z score (by subtracting the mean from the potential new value and dividing by SD) but need to use an equation to convert the z score to a % as my data-set has approximately 40 billion points ruling out the manual table method (i could use some kind of automated table lookup but a smaller equation would be preferable). For this purpose is the equation above the equation i should be using? if so I'm assuming in the equation z is the calculated z score and x is the new potential value but what do the e and dx signify? i know this has something to do with anti-derivatives but everything i look at on the net regarding these makes my brain hurt, can you dumb it down a notch? or point be in the right direction to a site that does?

P.S. If any other lads or ladies out there have any idea's please let me know

4. ## Re: Z-Score to Percentile Formula?

The equation I gave will give you the area between -z and z. x is a "dummy" variable, dx is the differential, and e is a noteworthy transcendental constant (the base of the natural logarithm). I am assuming you are using a programming language, and it may have an intrinsic function that will calculate this for you.

5. ## Re: Z-Score to Percentile Formula?

I am using some programing language but I'd really like to wrap my head around the maths beforehand. I'm afraid my knowledge of calculus is rather infantile (i.e. a couple of hours so far) but i think I follow that the equation is finding the anti-derivative of the equation/function of a bell curve, or in this case a segment of a bell curve as defined by the upper and lower levels of integration (0 and z), i reckon whats throwing me is the equation for the bell curve, would it be possible for you to put up the original function you used for the bell curve (as the ones on the net are confusing in the context of this equation) and explain how you rearranged it?

P.S. apologies for my mathematical incompetence...

6. ## Re: Z-Score to Percentile Formula?

Hi Mattrnfnr!

Using functions that are available on graphical calculators, the formula would be:
$p = \text{normcdf}(z) - \text{normcdf}(-z)$
The inverse is:
$z = \text{norminv}(\frac 1 2 p + \frac 1 2)$

So if you want a 95% confidence interval, you need:
$z = \text{norminv}(\frac 1 2 \cdot 0.95 + \frac 1 2) = \text{norminv}(0.975)$

Btw, the normcdf(z) function is defined as:

$\text{normcdf}(z) = \frac{1}{\sqrt{2\pi}}\int_{-\infty}^z e^{- \dfrac 1 2 x^2} dx$

Another name for the same function is $\Phi(z)$.
This is the formula Mark referred to (with a few slight modifications... )

7. ## Re: Z-Score to Percentile Formula?

It’s handy to know how to double check using the graphics calculator for small data-sets but I have 40 billion data points and need to write code using the underlying mathematics, this is where my issue is I need to interpret the equation in a way that I can use, such that I can calculate the % confidence interval associated with the z value for the given data point in a given data-set.

If I'm going to calculate a value i can't use an equation with infinity in it:

So I'd have to use the original equation:

but i don't understand how to interpret it as something in which i can put values:

I understand this segment:

(Although I've no idea why I'm taking the square root of 2 divided by pi)

but not this segment:

i have the z value, the sample size, the mean, standard deviation and the subject data value and need the confidence as a % that the subject data value fits the trend...

8. ## Re: Z-Score to Percentile Formula?

The proper bell curve with a mean $\mu$ and a standard deviation $\sigma$ is (see wiki):
$f(x)= \frac{1}{\sigma\sqrt{2\pi}} e^{- \dfrac{(x-\mu)^2}{2\sigma^2}}$

The constant $\sqrt{\frac 2 \pi}$ is wrong. It is a typo.
The reason for the $\frac 1 {\sqrt{2\pi}}$ is to make sure that when all possible z-values are integrated (from $-\infty$ to $+\infty$), we find a probability of exactly 1.

Your 95% interval corresponds with:
$\frac{1}{\sqrt{2\pi}} \int_{-z}^{+z} e^{-\frac 1 2 x^2} dx = 0.95$

The corresponding z-value is $z=1.96$.

The section $e^{-\frac 1 2 x^2}$ is the exponential function.

An alternative way to write it, is: $\exp(-\frac 1 2 x^2)$.
All programming languages support this $\exp()$ function.

9. ## Re: Z-Score to Percentile Formula?

So if I understand correctly (and history suggests I don’t) an equation for the % confidence that a new value belongs to the data-set, would vaguely resemble:

[1/(SQRT(2*π))]*[(exp(-(1/2*(+z^2)))) - (exp(-(1/2*(-z^2))))]

Where z = ((new value – mean of existing data)/standard deviation of the existing data)

10. ## Re: Z-Score to Percentile Formula?

Originally Posted by ILikeSerena
...
The constant $\sqrt{\frac 2 \pi}$ is wrong. It is a typo...
Just so the OP understands, I used the even function rule to state:

$\frac{1}{\sqrt{2\pi}}\int_{-z}^z e^{-\frac{x^2}{2}}\,dx=\frac{2}{\sqrt{2\pi}}\int_{0}^z e^{-\frac{x^2}{2}}\,dx=\sqrt{\frac{2}{\pi}}\int_{0}^z e^{-\frac{x^2}{2}}\,dx$

11. ## Re: Z-Score to Percentile Formula?

Originally Posted by MarkFL2
Just so the OP understands, I used the even function rule to state:

$\frac{1}{\sqrt{2\pi}}\int_{-z}^z e^{-\frac{x^2}{2}}\,dx=\frac{2}{\sqrt{2\pi}}\int_{0}^z e^{-\frac{x^2}{2}}\,dx=\sqrt{\frac{2}{\pi}}\int_{0}^z e^{-\frac{x^2}{2}}\,dx$
Oops. Sorry. It was not a typo.

12. ## Re: Z-Score to Percentile Formula?

Originally Posted by Mattrnfnr
So if I understand correctly (and history suggests I don’t) an equation for the % confidence that a new value belongs to the data-set, would vaguely resemble:

[1/(SQRT(2*π))]*[(exp(-(1/2*(+z^2)))) - (exp(-(1/2*(-z^2))))]

Where z = ((new value – mean of existing data)/standard deviation of the existing data)
Hmm, you left out the integral sign.
It means the result will be wrong.

You would get something with an expression in (+z) from which you subtract the same expression in (-z).
And yes, this is more or less how the formula can be programmed in a programming language.
You do need to take care with the parentheses.
As it is you need a couple of extra near -z: it should be (-z)^2 instead of just -z^2.

Let's take a look at an example.
Suppose you have z=1.
Then the corresponding confidence interval has a probability of 68%.
If we fill it in in your formula, we'd get:

[1/(SQRT(2*π))]*[(exp(-(1/2*((+1)^2)))) - (exp(-(1/2*((-1)^2))))]

= [1/(SQRT(2*π))]*[exp(-1/2) - exp(-1/2)]

= [1/(SQRT(2*π))]*[ 0 ]

= 0

No, this does not look like the right result.

13. ## Re: Z-Score to Percentile Formula?

I'm not sure what you mean by 'left out the integral sign', isn't this expression [(exp(-(1/2*((+1)^2)))) - (exp(-(1/2*((-1)^2))))] equivalent to the integral section? the upper integration limit plugged into the expression after the integral sign - the lower integration limit plugged into the expression after the integral sign?

I see I'm getting the wrong value, I'm just not sure what i need to do about it...

14. ## Re: Z-Score to Percentile Formula?

P.S. once again i apologize for my tenuous grasp of mathematics...

15. ## Re: Z-Score to Percentile Formula?

Originally Posted by Mattrnfnr
I see I'm getting the wrong value, I'm just not sure what i need to do about it...
Find a library that calculates the normcdf function I mentioned earlier.

Page 1 of 2 12 Last