Commit 11125e73 authored by Katter, Janike Yvonne's avatar Katter, Janike Yvonne
Browse files

Create lmcurve2.pod and change other man pages accordingly

parent a990a847
Pipeline #38836 passed with stage
in 11 seconds
......@@ -25,15 +25,16 @@ endfunction()
man ALL
DEPENDS lmcurve.3 lmmin.3 lmmin2.3 lmfit.7
DEPENDS lmcurve.3 lmcurve2.3 lmmin.3 lmmin2.3 lmfit.7
html ALL
DEPENDS lmcurve.html lmmin.html lmmin2.html lmfit.html
DEPENDS lmcurve.html lmcurve2.html lmmin.html lmmin2.html lmfit.html
one_page(lmcurve 3)
one_page(lmcurve2 3)
one_page(lmmin 3)
one_page(lmmin2 3)
one_page(lmfit 7)
=begin html
<link rel="stylesheet" href="podstyle.css" type="text/css" />
=end html
=head1 NAME
lmcurve2 - Levenberg-Marquardt least-squares fit of a curve (t,y,dy)
B<#include <lmcurve2.h>>
B<void lmcurve2(
const int> I<n_par>B<, double *>I<par>B<,
double *>I<parerr>B<, double *>I<covar>B<,
const int> I<m_dat>B<, constS< >double *>I<t>B<,
constS< >double *>I<y>B<, constS< >double *>I<dy>B<,
double (*>I<f>B<)( const double >I<ti>B<, const double *>I<par>B< ),
constS< >lm_control_struct *>I<control>B<,
lm_status_struct *>I<status>B<);>
B<extern const lm_control_struct lm_control_double;>
B<extern const lm_control_struct lm_control_float;>
B<extern const char *lm_infmsg[];>
B<extern const char *lm_shortmsg[];>
B<lmcurve2()> wraps the more generic minimization function B<lmmin2()>, for use in curve fitting.
B<lmcurve2()> determines a vector I<par> that minimizes the sum of squared elements of a residue vector I<r>[i] := (I<y>[i] - I<f>(I<t>[i];I<par>)) / I<dy>[i]. Typically, B<lmcurve2()> is used to approximate a data set I<t>,I<y>,I<dy>, where I<dy> represents the standard deviation of empirical data I<y>, by a parametric function I<f>(I<ti>;I<par>). On success, I<par> represents a local minimum, not necessarily a global one; it may depend on its starting value. Users must ensure that all I<dy>[i] are positive.
Function arguments:
=item I<n_par>
Number of free variables.
Length of parameter vector I<par>.
=item I<par>
Parameter vector.
On input, it must contain a reasonable guess.
On output, it contains the solution found to minimize ||I<r>||.
=item I<parerr>
Parameter uncertainties vector.
Array of length I<n_par> or B<NULL>.
On output, unless it or I<covar> is B<NULL>, it contains the weighted parameter uncertainties for the found parameters.
=item I<covar>
Covariance matrix.
Array of length I<n_par> * I<n_par> or B<NULL>.
On output, unless it is B<NULL>, it contains the covariance matrix.
=item I<m_dat>
Number of data points.
Length of vectors I<t>, I<y>, I<dy>.
Must statisfy I<n_par> <= I<m_dat>.
=item I<t>
Array of length I<m_dat>.
Contains the abcissae (time, or "x") for which function I<f> will be evaluated.
=item I<y>
Array of length I<m_dat>.
Contains the ordinate values that shall be fitted.
=item I<dy>
Array of length I<m_dat>.
Contains the standard deviations of the values I<y>.
=item I<f>
A user-supplied parametric function I<f>(ti;I<par>).
=item I<control>
Parameter collection for tuning the fit procedure.
In most cases, the default &I<lm_control_double> is adequate.
If I<f> is only computed with single-precision accuracy,
I<&lm_control_float> should be used.
Parameters are explained in B<lmmin2(3)>.
=item I<status>
A record used to return information about the minimization process:
For details, see B<lmmin2(3)>.
=head1 EXAMPLE
Fit a data set y(x) with standard deviations dy(x) by a curve f(x;p):
#include "lmcurve2.h"
#include <stdio.h>
/* model function: a parabola */
double f( double t, const double *p )
return p[0] + p[1]*t + p[2]*t*t;
int main()
int n = 3; /* number of parameters in model function f */
double par[3] = { 100, 0, -10 }; /* really bad starting value */
double parerr[3];
double covar[3*3];
/* data points: a slightly distorted standard parabola */
int m = 9;
int i;
double t[9] = { -4., -3., -2., -1., 0., 1., 2., 3., 4. };
double y[9] = { 16.6, 9.9, 4.4, 1.1, 0., 1.1, 4.2, 9.3, 16.4 };
double dy[9] = { 4, 3, 2, 1, 2, 3, 4, 5, 6 };
lm_control_struct control = lm_control_double;
lm_status_struct status;
control.verbosity = 1;
printf( "Fitting ...\n" );
/* now the call to lmfit */
lmcurve2( n, par, parerr, covar, m, t, y, dy, f, &control, &status );
printf( "Results:\n" );
printf( "status after %d function evaluations:\n %s\n",
status.nfev, lm_infmsg[status.outcome] );
printf("obtained parameters:\n");
for ( i = 0; i < n; ++i)
printf(" par[%i] = %12g uncertainty = %12g\n", i, par[i], parerr[i]);
printf("obtained norm:\n %12g\n", status.fnorm );
printf("fitting data as follows:\n");
for ( i = 0; i < m; ++i)
" t[%1d]=%2g y=%5.1f+-%4.1f fit=%8.5f residue=%8.4f weighed=%8.4f\n",
i, t[i], y[i], dy[i], f(t[i],par), y[i] - f(t[i],par),
(y[i] - f(t[i],par))/dy[i] );
return 0;
=head1 COPYING
Copyright (C) 2009-2015 Joachim Wuttke, Forschungszentrum Juelich GmbH
Software: FreeBSD License
Documentation: Creative Commons Attribution Share Alike
=head1 SEE ALSO
=begin html
<a href=""><b>lmmin2</b>(3)</a>
Homepage: <a href=""></a>
=end html
=begin man
=end man
=head1 BUGS
Please send bug reports and suggestions to the author <>.
......@@ -17,13 +17,15 @@ B<lmfit> is a C library for Levenberg-Marquardt least-squares minimization and c
For fitting a data set {(x_i,y_i)|i=0,1,..} by a parametric curve f(x,t), see B<lmcurve>(3).
For fitting a data set {(x_i,y_i+-dy_i)|i=0,1,..} by a parametric curve f(x,t), see B<lmcurve2>(3).
For generic minimization of the Eucledian norm of parametric vector, see B<lmmin2>(3).
For the simpler legacy API without error estimates, see B<lmmin>(3).
For an example how to use B<lmmin>, see the source files I<lmcurve.h> and I<lmcurve.c>. Do not patch these files; copy and modify them to create your own, differently named version of I<lmcurve_data_struct>, I<lmcurve_evaluate>, and I<lmcurve>.
For an example how to use B<lmmin2> for weighted data, see the source files I<lmcurve_tyd.h> and I<lmcurve_tyd.c>. Do not patch these files; copy and modify them to create your own, differently named version of I<lmcurve_tyd_data_struct>, I<lmcurve_tyd_evaluate>, and I<lmcurve_tyd>.
For an example how to use B<lmmin2> for weighted data, see the source files I<lmcurve2.h> and I<lmcurve2.c>. Do not patch these files; copy and modify them to create your own, differently named version of I<lmcurve2_data_struct>, I<lmcurve2_evaluate>, and I<lmcurve2>.
=head1 COPYING
......@@ -50,7 +52,7 @@ Homepage: <a href="">https://jugit.fz-jueli
=begin man
\fBlmcurve\fR(3), \fBlmmin\fR(3), \fBlmmin2\fR(3)
\fBlmcurve\fR(3), \fBlmcurve2\fR(3), \fBlmmin\fR(3), \fBlmmin2\fR(3)
......@@ -316,6 +316,7 @@ Homepage: <a href="">https://jugit.fz-jueli
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment