Solved

Normal Distribution with PHP

Posted on 2006-11-07
5
2,827 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

708 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

12 Experts available now in Live!

Get 1:1 Help Now