Solved

Normal Distribution with PHP

Posted on 2006-11-07
5
2,856 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

726 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