diff --git a/public/js/calculators.js b/public/js/calculators.js index 64e839d..133b4d7 100644 --- a/public/js/calculators.js +++ b/public/js/calculators.js @@ -736,7 +736,7 @@ } // Convert Z to percentile using standard normal CDF approximation var p = normalCDF(z); - return { z: z, percentile: Math.round(p * 1000) / 10 }; + return { z: z, percentile: Math.round(p * 10000) / 100 }; } function normalCDF(z) { @@ -1115,7 +1115,7 @@ } function renderGrowthResult(label, value, unit, z, percentile) { - var pctl = Math.round(percentile * 10) / 10; + var pctl = (Math.round(percentile * 100) / 100).toFixed(2); var cl; if (pctl >= 95 || pctl <= 5) cl = { color: '#f59e0b', bg: '#fef3c7', text: pctl <= 5 ? 'Below 5th percentile' : 'Above 95th percentile' }; else if (pctl >= 85 || pctl <= 15) cl = { color: '#f97316', bg: '#ffedd5', text: pctl + 'th percentile' }; @@ -1207,7 +1207,7 @@ // Calculate what percentile the MPH corresponds to using adult height LMS (~18y = 216mo) var adultLms = interpolateLMS(cdcLfaLMS[sex], 216); var mphZ = calcZFromLMS(mph.target, adultLms.L, adultLms.M, adultLms.S); - var mphPctile = Math.round(normalCDF(mphZ) * 1000) / 10; + var mphPctile = (Math.round(normalCDF(mphZ) * 10000) / 100).toFixed(2); resultDiv.innerHTML += '