add numerical recipes library
This commit is contained in:
23
lib/nr/cpp/recipes/ksone.cpp
Normal file
23
lib/nr/cpp/recipes/ksone.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <cmath>
|
||||
#include "nr.h"
|
||||
using namespace std;
|
||||
|
||||
void NR::ksone(Vec_IO_DP &data, DP func(const DP), DP &d, DP &prob)
|
||||
{
|
||||
int j;
|
||||
DP dt,en,ff,fn,fo=0.0;
|
||||
|
||||
int n=data.size();
|
||||
sort(data);
|
||||
en=n;
|
||||
d=0.0;
|
||||
for (j=0;j<n;j++) {
|
||||
fn=(j+1)/en;
|
||||
ff=func(data[j]);
|
||||
dt=MAX(fabs(fo-ff),fabs(fn-ff));
|
||||
if (dt > d) d=dt;
|
||||
fo=fn;
|
||||
}
|
||||
en=sqrt(en);
|
||||
prob=probks((en+0.12+0.11/en)*d);
|
||||
}
|
||||
Reference in New Issue
Block a user