Preface: I am not a mathematician. I have a basic understanding of statistics but am not familiar with mathematical notation beyond high school algebra.
I am a software developer maintaining medical records forms for a clinic. We have a form that calculates pediatric patients' height, weight, BMI, and other growth-related percentiles. In the process of troubleshooting a probably unrelated issue with the percentile calculations, I encountered this function that I do not understand.
This function takes only the z-score as an argument and returns a number percentile. I was able to confirm that the method to derive the z-score is correct (it is based on the LMS method outlined in this nature.com article), but I don't understand what is going on in the percentile calculation.
Code in MEL, a scripting language created in the mid 90's by GE:
local p10
local p9
local p4
local p3
local p2
local p1
local p
p10 = 1 + (0.33267 * AbsValue(zScore))
p9 = 1 / p10
p4 = (0.4361836 * p9) - (0.1201676 * (p9 ^ 2)) + (0.937298 * (p9 ^ 3))
p1 = 2 * 3.14159265
p3 = (AbsValue(zScore)^2)
p2 = -1 * p3 / 2
local pp
pp = 1 / (p1 ^ 0.5) * (2.71828182845905 ^ p2) * p4
p = 1 - pp
if zScore > 0 then
p = p * 100
else
p = 100 - p * 100
endif
p = div((p + 0.5), 1)
return p
Is the calculation correct? (I know it's at least close, I can cross-check against a table.) If it is correct, is it specific to the LMS growth chart tables (from the CDC/WHO) in some way, or can it be generalized? Can anyone offer any insight into what is going on here? Even if it is all correct and should not be changed, I would like to name the variables more descriptively and add some comments about what calculations are being done and why.
I have been searching on this question all day and can find only either a) explanations on how to find a percentile by looking a z-score up on a table and b) explanations involving formulas full of unfamiliar notation that I don't even know where to start to understand.
- I don't think the issue I was troubleshooting is related to this code, but it's hard to be sure without understanding the parts.
- I found this question but looking through the links in the answer and comments there did not lead me to anything I found useful.