/* testpafit.c Example program for the computation of piece-wise analytic fits to probability distribution functions, based on sample data. Ramses van Zon, December 5, 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 "pa.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 */ int main( int argc, char **argv ) { int m, n; double q, y, y1, y2, dy, *r; struct Pafit *fit; r = readbinfile(argv[1], &y1, &y2, &m, &n); printf("#Read %d numbers from file %s\n", n, argv[1]); printf("#y1=%6.3f y2=%6.3f m=%d\n", y1, y2, m); printf("#Performing pa analysis\n"); fit = paalloc(km,mm); pasort(n,r); q = pafit(n,r,qm,km,mm,1,fit); free(r); printf("#Writing distribution at %d points\n", m); dy = (y2-y1)/m; for (y = y1;y <= y2; y += dy) printf("%f %f %f\n", y, papd(y,fit), pacd(y,fit)); printf("#Parameters (q=%f):\n", q); pawrite(stdout,fit); pafree(fit); }