/* testpaxx.cc Example program for the computation of piece-wise analytic fits to probability distribution functions, based on sample data. Ramses van Zon, December 13, 2009 Reference: [] Ramses van Zon and Jeremy Schofield, "Constructing smooth potentials of mean force, radial distribution functions and probability densities from sampled data", arxiv.0912.0465 [cond-mat.stat-mech]. */ #include #include #include "paxx.h" const int km = 21; /* maximum number of intervals */ const int mm = 14; /* maximum number of Fourier modes per interval */ const double qm = 0.6; /* satisfactory value for Q */ using namespace std; using namespace pa; int main( int argc, char **argv ) { int m, n; double y1, y2; double *r = newreadbinfile(argv[1], y1, y2, m, n); cout << "#Read " << n << " numbers from file " << argv[1] << "\n" << "#y1=" << y1 << " y2=" << y2 << " m=" << m << "\n" << "#Performing pa analysis" << endl; sort(r,r+n); Fit fit; double q = fit.fit(n,r,qm,km,mm,1); delete[] r; cout << "#Writing distribution at " << m << " points" << endl; double dy = (y2-y1)/m; for (double y = y1;y <= y2; y += dy) cout << y << " " << fit.pd(y) << " " << fit.cd(y) << "\n"; cout << "#Parameters (q=" << q << "):" << endl; fit.write(stdout); }