Algorithm-CurveFit-Simple

 view release on metacpan or  search on metacpan

LICENSE  view on Meta::CPAN

TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

                     END OF TERMS AND CONDITIONS

        Appendix: How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.

  To do so, attach the following notices to the program.  It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) 19yy  <name of author>

bin/curvefit  view on Meta::CPAN

    print STDOUT $log_rec if (opt('show-log-to-stdout'));
    File::Valet::ap_f(opt('logfile',"/home/ttk/$PROJECT_NAME.log"), $log_rec) unless(opt('no-logfile'));
    return;
}

sub usage {
    print <<USAGE;
Usage: $0 [options] < data
Input must be x,y data pairs, one pair per line, separated by a comma or tab.
Options and their defaults, if any:
    --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
See also: Algorithm::CurveFit::Simple

bin/curvefit  view on Meta::CPAN

=head1 NAME

curvefit - Fit a polynomial to data points

=head1 SYNOPSIS

  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

lib/Algorithm/CurveFit/Simple.pm  view on Meta::CPAN

our %STATS_H;  # side-products of fit() stored here for profiling purposes

BEGIN {
    require Exporter;
    our $VERSION = '1.03';
    our @ISA = qw(Exporter);
    our @EXPORT_OK = qw(fit %STATS_H);
}

# fit() - only public function for this distribution
# Given at least parameter "xy", generate a best-fit curve within a time limit.
# Output: max deviation, avg deviation, implementation source string (perl or C, for now).
# Optional parameters and their defaults:
#    terms       => 3      # number of terms in formula, max is 10
#    time_limit  => 3      # number of seconds to try for better fit
#    inv         => 1      # invert sense of curve-fit, from x->y to y->x
#    impl_lang   => 'perl' # programming language used for output implementation: perl, c
#    impl_name   => 'x2y'  # name given to output implementation function
sub fit {
    my %p = @_;

lib/Algorithm/CurveFit/Simple.pm  view on Meta::CPAN

=back

=head1 TO DO

=over 4

=item * Support more programming languages for formula implementation: R, MATLAB, python

=item * Calculate the actual term sigfigs and set precision appropriately in the formula implementation instead of just "%.11f".

=item * Support trying a range of terms and returning whatever gives the best fit.

=item * Support piecewise output formulas.

=item * Work around L<Algorithm::CurveFit>'s occasional hang problem when using ten-term polynomials.

=back

=head1 SEE ALSO

L<Algorithm::CurveFit>



( run in 0.480 second using v1.01-cache-2.11-cpan-4e96b696675 )