curvefit - Fit a polynomial to data points
Usage: curvefit [options] < data Expects x,y data pairs on STDIN, one pair per line, separated by a comma or tab. --time-limit=3 Maximum number of seconds to spend calculating best fit --iterations=# Maximum number of iterations to spend calculating best fit (default is to use a time limit) --terms=3 Number of terms in polynomial, max 10 --inv Invert the sense of the fit to f(y) = x --impl-lang=perl Language used for output implementation: perl, C --impl-name=x2y Name of function in output implementation --bounds-check Implementation will check for out-of-bounds input --round-result Implementation will round output to nearest integer --suppress-includes (C only) Do not put #include directives in output implementation --quiet Do not write supplementary information to stderr --profile Dump %STATS_H to STDERR as json
This is a thin wrapper around Algorithm::CurveFit::Simple, which is in turn a convenience wrapper around Algorithm::CurveFit.
Given a set of x,y data pairs on STDIN, it will generate a polynomial formula f(x) = y which fits that data, and write a source code implementation of that formula to STDOUT.
Additionally it will write a maximum deviation and average deviation to STDERR. Closer to 1.0 is better. Play with --terms=# until these deviations are as close to 1.0 as possible, and beware overfitting. Use --quiet to suppress this information.
Algorithm::CurveFit::Simple
To install Algorithm::CurveFit::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Algorithm::CurveFit::Simple
CPAN shell
perl -MCPAN -e shell install Algorithm::CurveFit::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.