Click here to Skip to main content
       

Algorithms

 
QuestionRe: I know, PinmvpCPallini3-Jul-08 1:11 
AnswerRe: I know, Pinmembersumit70343-Jul-08 1:28 
GeneralRe: I know, Pinmembercp98763-Jul-08 1:52 
GeneralRe: I know, PinmvpCPallini3-Jul-08 1:56 
GeneralRe: I know, Pinmembersumit70343-Jul-08 2:36 
GeneralRe: I know, PinmemberPaul Conrad3-Jul-08 19:32 
GeneralRe: I know, PinmvpCPallini3-Jul-08 1:53 
AnswerRe: NORMSDIST function Pinmember73Zeppelin3-Jul-08 3:11 
Implementation 1:
 
// returns the cumulative normal distribution function (CNDF)
// for a standard normal: N(0,1)
double CNDF(double x)
{
	int neg = (x < 0);
	if ( neg ) 
		x *= -1;
 
	double k(1/(1+0.2316419*x));
	double y=((((1.330274429*k-1.821255978)*k+1.781477937)*k-0.356563782)*k+0.319381530)*k;
	y = 1.0 - 0.398942280401*exp(-0.5*x*x)*y;
	
	return (1-neg)*y + neg*(1-y);
}
 
Implementation 2
 
// another implementation of the CNDF
// for a standard normal: N(0,1)
double CumNorm(double x)
{
	// protect against overflow
	if (x > 6.0)
		return 1.0;
	if (x < -6.0)
		return 0.0;
 
	double b1 = 0.31938153;
	double b2 = -0.356563782;
	double b3 = 1.781477937;
	double b4 = -1.821255978;
	double b5 = 1.330274429;
	double p = 0.2316419;
	double c2 = 0.3989423;
 
	double a = fabs(x);
	double t = 1.0 / (1.0 + a * p);
	double b = c2*exp((-x)*(x/2.0));
	double n = ((((b5*t+b4)*t+b3)*t+b2)*t+b1)*t;
	n = 1.0-b*n;
	
	if ( x < 0.0 )
		n = 1.0 - n;
	
	return n;
}

 
I'm the ocean. I'm a giant undertow.

QuestionRe: NORMSDIST function PinmvpCPallini3-Jul-08 3:29 
AnswerRe: NORMSDIST function Pinmember73Zeppelin3-Jul-08 4:19 
GeneralRe: NORMSDIST function Pinmembersumit70343-Jul-08 3:47 
GeneralRe: NORMSDIST function PinmemberMember 82494621-Dec-11 0:54 
GeneralThe six rightmost non-zero digits of 1000000! PinmemberRod Gowdy2-Jul-08 5:50 
GeneralRe: The six rightmost non-zero digits of 1000000! [modified] PinmemberRobert.C.Cartaino2-Jul-08 7:33 
GeneralRe: The six rightmost non-zero digits of 1000000! PinmemberRod Gowdy3-Jul-08 4:42 
GeneralRe: The six rightmost non-zero digits of 1000000! PinmemberRobert.C.Cartaino3-Jul-08 11:06 
QuestionSpecify numbers as product of Primes? PinmemberIan Uy25-Jun-08 20:37 
AnswerRe: Specify numbers as product of Primes? Pinmembercp987625-Jun-08 22:32 
GeneralRe: Specify numbers as product of Primes? PinmemberIan Uy26-Jun-08 1:42 
AnswerRe: Specify numbers as product of Primes? PinmemberRobert.C.Cartaino26-Jun-08 5:48 
GeneralRe: Specify numbers as product of Primes? PinmemberIan Uy26-Jun-08 5:50 
GeneralRe: Specify numbers as product of Primes? PinmemberThe Developer8-Aug-08 8:03 
GeneralRe: Specify numbers as product of Primes? PinmemberIan Uy26-Jun-08 7:28 
GeneralRe: Specify numbers as product of Primes? PinmemberPaul Conrad28-Jun-08 6:44 
GeneralRe: Specify numbers as product of Primes? PinmemberIan Uy28-Jun-08 6:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 13 Dec 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid