Solved

Normal Distribution with PHP

Posted on 2006-11-07
5
2,833 Views
Last Modified: 2007-12-19
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.  
0
Comment
Question by:south_paw
  • 3
5 Comments
 

Author Comment

by:south_paw
ID: 17892062
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
0
 

Author Comment

by:south_paw
ID: 17892155
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;

0
 

Author Comment

by:south_paw
ID: 17892203
Please close Q and refund points, I solved all by my lelf.
0
 
LVL 49

Expert Comment

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

-r-
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 17920614
Closed, 500 points refunded.
CetusMOD
Community Support Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now