Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: afe6673818
Fetching contributors…

Cannot retrieve contributors at this time

23 lines (19 sloc) 0.44 kB
function phi(x)
-- constants
a1 = 0.254829592
a2 = -0.284496736
a3 = 1.421413741
a4 = -1.453152027
a5 = 1.061405429
p = 0.3275911
-- Save the sign of x
sign = 1
if x < 0 then
sign = -1
end
x = math.abs(x)/math.sqrt(2.0)
-- A&S formula 7.1.26
t = 1.0/(1.0 + p*x)
y = 1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*math.exp(-x*x)
return 0.5*(1.0 + sign*y)
end
Jump to Line
Something went wrong with that request. Please try again.