We help IT Professionals succeed at work.

Normal Distribution with PHP

on
Medium Priority
3,137 Views
Anyone know how to find the normal distribution value using PHP?  I have mean, std dev, and the z-score.

Excel finds it via NORMSDIST(z).  I want to hand code it, something like:

\$normdist(\$zScore) = //calc for norms

Or would I be better off using javascript?

Any ideas appreciated.
Comment
Watch Question

View Solution Only

Commented:
I found this on the web, I'm going to try to convert it....

Help appreciated!

Function u_SNorm(z)

c1 = 2.506628
c2 = 0.3193815
c3 = -0.3565638
c4 = 1.7814779
c5 = -1.821256
c6 = 1.3302744
If z > 0 Or z = 0 Then
w = 1
Else: w = -1
End If
y = 1 / (1 + 0.2316419 * w * z)
u_SNorm = 0.5 + w * (0.5 - (Exp(-z * z / 2) / c1) * _
(y * (c2 + y * (c3 + y * (c4 + y * (c5 + y * c6))))))

End Function

Commented:
I think i just answered my on Qeustion:

\$c1 = 2.506628;
\$c2 = 0.3193815;
\$c3 = -0.3565638;
\$c4 = 1.7814779;
\$c5 = -1.821256;
\$c6 = 1.3302744;
if (\$z1 > 0 )
\$w = 1;
else \$w = -1;

\$y = 1 / (1 + 0.2316419 * \$w * \$z1);
\$normDist = 0.5 + \$w * (0.5 - (exp(-\$z1 * \$z1 / 2) / \$c1) * _
(\$y * (\$c2 + \$y * (\$c3 + \$y * (\$c4 + \$y * (\$c5 + \$y * \$c6))))));

echo \$normDist;

Commented:
Please close Q and refund points, I solved all by my lelf.
CERTIFIED EXPERT
Top Expert 2006

Commented:
You can request a refund by posting in the community support area. See the "support" link in the topright menu.

-r-
Commented:
Closed, 500 points refunded.
CetusMOD
Community Support Moderator

Not the solution you were looking for? Getting a personalized solution is easy.

Thanks for using Experts Exchange.

• View three pieces of content (articles, solutions, posts, and videos)
• Ask the experts questions (counted toward content limit)
• Customize your dashboard and profile