Wikipedia:Reference desk/Archives/Mathematics/2014 August 4

= August 4 =

P value calculation
I have been trying to figure out how to covert a z score to a p value. Oracle does not have a built-in function for this. Please let me know if the following seems in any way at all valid. I derived it from reading a plethora of methods to do what appears to be a rather common conversion. What I am getting appears to be high, but when I check known z score to p value conversions, I get the correct value. That is why I am hoping for some validation that what I am doing is correct. — Preceding unsigned comment added by 209.149.115.166 (talk) 13:52, 4 August 2014 (UTC)
 * pi = PI, 3.14159... Oracle does not have PI, so I set it to asin(2)*2
 * x = z score divided by the square root of 2
 * ap = (8*(pi-3))/(3*pi*(4-pi)) - I have no idea what this does or why, I just saw it used a lot
 * If Z<0, I use: 100*((1-sqrt(1-exp(-1*x*x*(4/pi+ap*x*x)/(1+ap*x*x))))/2)
 * Otherwise, I use: 100*((1+sqrt(1-exp(-1*x*x*(4/pi+ap*x*x)/(1+ap*x*x))))/2)
 * You can't set PI to asin(2)*2 because asin( x ) where x is outside the range -1 ... +1 is NaN. Try one of these: asin(1)*2; atan(1)*4; acos(0.5)*3; or asin(0.5)*6 -- Red rose64 (talk) 15:18, 4 August 2014 (UTC)