1builddir::build::BUILD::lmbfuiitl-dvd8i.r2l:.m:2fb:iu:timlamdna::n::uBlaUmlIcLuDr:v:el(m3f)it-v8.2.2::man::lmcurve(3)
2
3
4

NAME

6       lmcurve - Levenberg-Marquardt least-squares fit of a curve (t,y)
7

SYNOPSIS

9       #include <lmcurve.h>
10
11       void lmcurve( const int n_par, double *par, const int m_dat,
12                     const double *t, const double *y,
13                     double (*f)( const double ti, const double *par ),
14                     const lm_control_struct *control,
15                     lm_status_struct *status);
16
17       void lmcurve_tyd(
18                     const int n_par, double *par, const int m_dat,
19                     const double *t, const double *y, const double *dy,
20                     double (*f)( const double ti, const double *par ),
21                     const lm_control_struct *control,
22                     lm_status_struct *status);
23
24       extern const lm_control_struct lm_control_double;
25
26       extern const lm_control_struct lm_control_float;
27
28       extern const char *lm_infmsg[];
29
30       extern const char *lm_shortmsg[];
31

DESCRIPTION

33       lmcurve() and lmcurve_tyd() wrap the more generic minimization function
34       lmmin(), for use in curve fitting.
35
36       lmcurve() determines a vector par that minimizes the sum of squared
37       elements of a residue vector r[i] := y[i] - f(t[i];par). Typically,
38       lmcurve() is used to approximate a data set t,y by a parametric
39       function f(ti;par). On success, par represents a local minimum, not
40       necessarily a global one; it may depend on its starting value.
41
42       lmcurve_tyd() does the same for a data set t,y,dy, where dy represents
43       the standard deviation of empirical data y. Residues are computed as
44       r[i] := (y[i] - f(t[i];par))/dy[i]. Users must ensure that all dy[i]
45       are positive.
46
47       Function arguments:
48
49       n_par
50           Number of free variables.  Length of parameter vector par.
51
52       par Parameter vector.  On input, it must contain a reasonable guess.
53           On output, it contains the solution found to minimize ||r||.
54
55       m_dat
56           Number of data points.  Length of vectors t and y.  Must statisfy
57           n_par <= m_dat.
58
59       t   Array of length m_dat.  Contains the abcissae (time, or "x") for
60           which function f will be evaluated.
61
62       y   Array of length m_dat.  Contains the ordinate values that shall be
63           fitted.
64
65       dy  Only in lmcurve_tyd().  Array of length m_dat.  Contains the
66           standard deviations of the values y.
67
68       f   A user-supplied parametric function f(ti;par).
69
70       control
71           Parameter collection for tuning the fit procedure.  In most cases,
72           the default &lm_control_double is adequate.  If f is only computed
73           with single-precision accuracy, &lm_control_float should be used.
74           Parameters are explained in lmmin(3).
75
76       status
77           A record used to return information about the minimization process:
78           For details, see lmmin(3).
79

EXAMPLE

81       Fit a data set y(x) by a curve f(x;p):
82
83           #include "lmcurve.h"
84           #include <stdio.h>
85
86           /* model function: a parabola */
87
88           double f( double t, const double *p )
89           {
90               return p[0] + p[1]*t + p[2]*t*t;
91           }
92
93           int main()
94           {
95               int n = 3; /* number of parameters in model function f */
96               double par[3] = { 100, 0, -10 }; /* really bad starting value */
97
98               /* data points: a slightly distorted standard parabola */
99               int m = 9;
100               int i;
101               double t[9] = { -4., -3., -2., -1.,  0., 1.,  2.,  3.,  4. };
102               double y[9] = { 16.6, 9.9, 4.4, 1.1, 0., 1.1, 4.2, 9.3, 16.4 };
103
104               lm_control_struct control = lm_control_double;
105               lm_status_struct status;
106               control.verbosity = 7;
107
108               printf( "Fitting ...\n" );
109               lmcurve( n, par, m, t, y, f, &control, &status );
110
111               printf( "Results:\n" );
112               printf( "status after %d function evaluations:\n  %s\n",
113                       status.nfev, lm_infmsg[status.outcome] );
114
115               printf("obtained parameters:\n");
116               for ( i = 0; i < n; ++i)
117                   printf("  par[%i] = %12g\n", i, par[i]);
118               printf("obtained norm:\n  %12g\n", status.fnorm );
119
120               printf("fitting data as follows:\n");
121               for ( i = 0; i < m; ++i)
122                   printf( "  t[%2d]=%4g y=%6g fit=%10g residue=%12g\n",
123                           i, t[i], y[i], f(t[i],par), y[i] - f(t[i],par) );
124
125               return 0;
126           }
127

COPYING

129       Copyright (C) 2009-2015 Joachim Wuttke, Forschungszentrum Juelich GmbH
130
131       Software: FreeBSD License
132
133       Documentation: Creative Commons Attribution Share Alike
134

SEE ALSO

136       lmmin(3)
137
138       Homepage: http://apps.jcns.fz-juelich.de/lmfit
139

BUGS

141       Please send bug reports and suggestions to the author
142       <j.wuttke@fz-juelich.de>.
143
144
145
146perl v5.32.1             builddir:2:0b2u1i-l0d1:-:2B6UILD::lmfit-v8.2.2::man::lmcurve(3)
Impressum