Click here to Skip to main content
15,887,746 members
Home / Discussions / Algorithms
   

Algorithms

 
QuestionRe: I know, Pin
CPallini3-Jul-08 0:11
mveCPallini3-Jul-08 0:11 
AnswerRe: I know, Pin
sumit70343-Jul-08 0:28
sumit70343-Jul-08 0:28 
GeneralRe: I know, Pin
cp98763-Jul-08 0:52
cp98763-Jul-08 0:52 
GeneralRe: I know, Pin
CPallini3-Jul-08 0:56
mveCPallini3-Jul-08 0:56 
GeneralRe: I know, Pin
sumit70343-Jul-08 1:36
sumit70343-Jul-08 1:36 
GeneralRe: I know, Pin
Paul Conrad3-Jul-08 18:32
professionalPaul Conrad3-Jul-08 18:32 
GeneralRe: I know, Pin
CPallini3-Jul-08 0:53
mveCPallini3-Jul-08 0:53 
AnswerRe: NORMSDIST function Pin
73Zeppelin3-Jul-08 2:11
73Zeppelin3-Jul-08 2: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 Pin
CPallini3-Jul-08 2:29
mveCPallini3-Jul-08 2:29 
AnswerRe: NORMSDIST function Pin
73Zeppelin3-Jul-08 3:19
73Zeppelin3-Jul-08 3:19 
GeneralRe: NORMSDIST function Pin
sumit70343-Jul-08 2:47
sumit70343-Jul-08 2:47 
GeneralRe: NORMSDIST function Pin
Member 82494620-Dec-11 23:54
Member 82494620-Dec-11 23:54 
GeneralThe six rightmost non-zero digits of 1000000! Pin
Rod Gowdy2-Jul-08 4:50
Rod Gowdy2-Jul-08 4:50 
GeneralRe: The six rightmost non-zero digits of 1000000! [modified] Pin
Robert.C.Cartaino2-Jul-08 6:33
Robert.C.Cartaino2-Jul-08 6:33 
GeneralRe: The six rightmost non-zero digits of 1000000! Pin
Rod Gowdy3-Jul-08 3:42
Rod Gowdy3-Jul-08 3:42 
GeneralRe: The six rightmost non-zero digits of 1000000! Pin
Robert.C.Cartaino3-Jul-08 10:06
Robert.C.Cartaino3-Jul-08 10:06 
QuestionSpecify numbers as product of Primes? Pin
Ian Uy25-Jun-08 19:37
Ian Uy25-Jun-08 19:37 
AnswerRe: Specify numbers as product of Primes? Pin
cp987625-Jun-08 21:32
cp987625-Jun-08 21:32 
GeneralRe: Specify numbers as product of Primes? Pin
Ian Uy26-Jun-08 0:42
Ian Uy26-Jun-08 0:42 
AnswerRe: Specify numbers as product of Primes? Pin
Robert.C.Cartaino26-Jun-08 4:48
Robert.C.Cartaino26-Jun-08 4:48 
GeneralRe: Specify numbers as product of Primes? Pin
Ian Uy26-Jun-08 4:50
Ian Uy26-Jun-08 4:50 
GeneralRe: Specify numbers as product of Primes? Pin
The Web Developer8-Aug-08 7:03
The Web Developer8-Aug-08 7:03 
GeneralRe: Specify numbers as product of Primes? Pin
Ian Uy26-Jun-08 6:28
Ian Uy26-Jun-08 6:28 
GeneralRe: Specify numbers as product of Primes? Pin
Paul Conrad28-Jun-08 5:44
professionalPaul Conrad28-Jun-08 5:44 
GeneralRe: Specify numbers as product of Primes? Pin
Ian Uy28-Jun-08 5:46
Ian Uy28-Jun-08 5:46 

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

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