This should do the trick.
For any normal distribution defined by the mean and SD, let myval be the value for which you want to find the centile.
If you want just to return the output of NORM.S.DIST in excel, just skip the centile function.
var myval = 14;
var mean = 15.5;
var SD = 4.8333;
var answer = centile(mean, SD, myval);
console.log(answer);
function centile(mean, SD, val)
{
z = (val-mean)/SD;
ans = NORMSDIST(z);
return ans;
}
function erf(x)
{
//A&S formula 7.1.26
var ans = 0;
var a1 = 0.254829592;
var a2 = -0.284496736;
var a3 = 1.421413741;
var a4 = -1.453152027;
var a5 = 1.061405429;
var p = 0.3275911;
x = Math.abs(x);
var t = 1 / (1 + p * x);
//Horner's method, takes O(n) operations for nth order polynomial
ans = 1 - ((((((a5 * t + a4) * t) + a3) * t + a2) * t) + a1) * t * Math.exp(-1 * x * x);
return ans;
}
function NORMSDIST(z)
{
var ans = 0;
var sign = 1;
if (z < 0) sign = -1;
ans = 0.5 * (1.0 + sign * erf(Math.abs(z)/Math.sqrt(2)));
return ans;
}
working pen:
https://codepen.io/RichClarke/pen/oNdpoRM?editors=0011