mitsuba-af602c6fd98a/src/tests/test_random.cpp
// Kolmogorov-Smirnov probability function.
// Taken from Numerical Recipes in C, 14.3
Kolmogorov-Smirnov probability function.
Taken from Numerical Recipes in C, 14.3
Kolmogorov - Smirnov probability function . Taken from Numerical Recipes in C 14 . 3
double probks(const double alam)
{
	const double EPS1=1.0e-6,EPS2=1.0e-16;
	double a2,fac=2.0,sum=0.0,term,termbf=0.0;
	a2 = -2.0*alam*alam;
	for (int j=1;j<=100;j++) {
		term=fac*exp(a2*j*j);
		sum += term;
		if (fabs(term) <= EPS1*termbf || fabs(term) <= EPS2*sum) return sum;
		fac = -fac;
		termbf=fabs(term);
	}
	return 1.0;
}
double probks ( const double alam ) { const double EPS1 = 1.0e-6 , EPS2 = 1.0e-16 ; double a2 , fac = 2.0 , sum = 0.0 , term , termbf = 0.0 ; a2 = -2.0 * alam * alam ; for ( int j = 1 ; j <= 100 ; j ++ ) { term = fac * exp ( a2 * j * j ) ; sum += term ; if ( fabs ( term ) <= EPS1 * termbf || fabs ( term ) <= EPS2 * sum ) return sum ; fac = - fac ; termbf = fabs ( term ) ; } return 1.0 ; }
Kolmogorov-Smirnov probability function.
Kolmogorov - Smirnov probability function .