in reply to Re^3: fitting double lognormal distribution on a dataset
in thread fitting double lognormal distribution on a dataset
I'll try to do the more complex equation and I let you know how it went! Thanks.#!/usr/bin/perl use strict; use warnings; use Algorithm::CurveFit; my @X_data = qw(-20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 - +6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14); my @Y_data = qw(1212 1095 984 879 780 687 600 519 444 375 312 255 204 +159 120 87 60 39 24 15 12 15 24 39 60 87 120 159 204 255 312 375 444 +519 600); my $variable = 'x'; my $equation = 'r + m * x^2'; my @parameters = ( ['r', '100'], ['m', '1'], ); my $maxiter = '200'; my $square_residual = Algorithm::CurveFit->curve_fit( formula => $equation, # may be a Math::Symbolic tree in +stead params => \@parameters, variable => $variable, xdata => \@X_data, ydata => \@Y_data, maximum_iterations => $maxiter, ); print "$parameters[0][1] (should be 12)\t$parameters[1][1] (should be +3)\n";
|
|---|