Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: fitting double lognormal distribution on a dataset

by sdani (Novice)
on May 19, 2013 at 03:48 UTC ( [id://1034189]=note: print w/replies, xml ) Need Help??


in reply to Re^3: fitting double lognormal distribution on a dataset
in thread fitting double lognormal distribution on a dataset

On an made up dataset the program runs fine. So the proper way to raise to the power is this: n ^ 2 not this: n**2; here is the sample code:
#!/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";
I'll try to do the more complex equation and I let you know how it went! Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1034189]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-26 08:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found