Reputation: 171
I am making a normal distribution calculator in PHP, but I can't figure out how to calculate the integral of a function using PHP. I've searched the web and stackoverflow, but I can't find anything on the topic. The closest I've come is via php.net where someone referrers to the Composite Simpson's Rule to get an approximation, but I would like to get a precise result and not just an approximation.
Is there any commonly know way to achieve my goal, that I am missing, and if there are several which would be the best for calculating normal distribution?
Upvotes: 3
Views: 3543
Reputation:
The integral of the normal distribution is known as the error function (often abbreviated as erf
). There doesn't appear to be any native implementation in PHP, but the Wikipedia page has several good approximations under "Approximation with elementary functions".
Upvotes: 3
Reputation: 55402
Except in certain trivial cases, it's not possible to precisely integrate the probability density function of the normal distribution.
Upvotes: 0