Subject: | bug report |
Date: | Mon, 02 Mar 2009 12:39:48 -0800 |
To: | bug-Algorithm-CurveFit [...] rt.cpan.org |
From: | Alexander Platt <platta [...] usc.edu> |
I don't know if this is a bug in CurveFit or a bug in Math::Symbolic.
The code below works just fine. Note, however, that the formula is written strangely. This is because while 'K+-C*exp(-L*x)' works, 'K-C*exp(-L*x)' does not. '-C*exp(-L*x)+K' also works.
#!/usr/bin/perl -w
use strict;
use Algorithm::CurveFit;
my $formula = 'K+-C*exp(-L*x)';
my $variable='x';
my @xdata=(0, 1, 2, 3, 4, 5, 6, 7);
my @ydata=(.2, .601, .8, .9, .948, .975, .98255, .99);
my @parameters=(['C', 0.8, 0.001],
['K', 1, 0.001],
['L', 1, 0.0001]);
my $max_iter=100;
my $square_residual=Algorithm::CurveFit->curve_fit(
formula=>$formula,
params=>\@parameters,
variable=>$variable,
xdata=>\@xdata,
ydata=>\@ydata,
maximum_iterations=>$max_iter
);
print "done\t";
--------------------------------------------------------------------------------
Alexander Platt
University of Southern California
Center of Excellence in Genome Science
Office 413J
1050 Childs Way
Los Angeles, CA 90089
phone: +1 213 821 3995
--------------------------------------------------------------------------------