CFLib.org – Common Function Library Project

CND(x)

Last updated March 10, 2003

Version: 1 | Requires: ColdFusion 5 | Library: MathLib

 
Rated 0 time(s). Average Rating: 0

Description:
Computes cumulative normal distribution function.

Return Values:
Returns a numeric value.

Example:

view plain print about
<cfoutput>
CND(3) = #CND(3)#
</cfoutput>

Parameters:

Name Description Required
x value for which you want to compute the cumulative normal distribution Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Cumulative Normal Distribution
 * 
 * @param x      value for which you want to compute the cumulative normal distribution (Required)
 * @return Returns a numeric value. 
 * @author Alex (axs@arbornet.org) 
 * @version 1, March 10, 2003 
 */

function CND (x) {
    // The cumulative normal distribution function
    var Pi = 3.141592653589793238;
    var a1 = 0.31938153;
    var a2 = -0.356563782;
    var a3 = 1.781477937;
    var a4 = -1.821255978;
    var a5 = 1.330274429;
    var L = abs(x);
    var k = 1 / ( 1 + 0.2316419 * L);
    var p = 1 - 1 /  ((2 * Pi)^0.5) * exp( -(L^2) / 2 ) * (a1 * k + a2 * (k^2) + a3 * (k^3) + a4 * (k^4) + a5 * (k^5) );

    if (x gte 0)
        return p;
    else
        return 1-p;

}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson