1

I've calculated a whole bunch of z-scores using mean and standard deviation, now I want them to be turned into percentiles. What is the way to do this in objective-c for an iPhone app?

I've only done this using a z-score chart in my stats class back in highschool.

I've found this equation to be the one I am trying to recreate:

enter image description here

and this thread Cumulative Normal Distribution function in objective C seems to be an answer, but I still don't understand what is going on. Can anyone please explain to me how this is all working? For example, what is the erfc function?

Will 0.5 * erfc(z-score * M_SQRT1_2); work?

Thanks in advance!

Community
  • 1
  • 1
sbjluke
  • 309
  • 5
  • 15
  • Well, start by finding the algorithm and then implementing it. This question is too vague. "I'm just not confident which is correct" between what and what? Come on give some information! – borrrden Nov 27 '13 at 04:12
  • you got it, check out the edits – sbjluke Nov 27 '13 at 04:19

2 Answers2

3

Alright, I've found the solutions.

enter image description here

enter image description here

The second equation returns the percentile where x is the z-score.

So 0.5 * (1 + erf(z_score*M_SQRT1_2)) is the answer to my question

also, erfc(x) = 1 - erf(x)

sbjluke
  • 309
  • 5
  • 15
0

I took Calculus, but never stats, and it's been too long for me to remember this stuff without a lot of effort. One thing I can offer is how to look up the erfc function. Open the terminal application and type "man erfc" That will give you the UNIX manual page for that function. Here's the first part of what it displays:

NAME erf, erfc -- error function operators

SYNOPSIS #include

 double
 erf(double x);

 long double
 erfl(long double x);

 float
 erff(float x);

 double
 erfc(double x);

 long double
 erfcl(long double x);

 float
 erfcf(float x);

DESCRIPTION These functions calculate the error function of x.

 The erf() function calculates the error function of x; where

       erf(x) = 2/sqrt(pi)*integral from 0 to x of exp(-t*t) dt.

 The erfc() function calculates the complementary error function of x; that is erfc() com-
 putes the difference of the error function erf(x) from 1.0.  This is useful, since for
 large x use of erfc() avoids loss of precision due to cancellation.

SPECIAL VALUES erf(+-0) returns +-0.

 erf(+-infinity) returns +-1.
Duncan C
  • 128,072
  • 22
  • 173
  • 272