mexpfit: Multi-exponential Fitting

View source: R/mexpfit.R

mexpfitR Documentation

Multi-exponential Fitting

Description

Multi-exponential fitting means fitting of data points by a sum of (decaying) exponential functions, with or without a constant term.

Usage

mexpfit(x, y, p0, w = NULL, const = TRUE, options = list())

Arguments

x, y

x-, y-coordinates of data points to be fitted.

p0

starting values for the exponentials alone; can be positive or negative, but not zero.

w

weight vector; not used in this version.

const

logical; shall an absolute term be included.

options

list of options for lsqnonlin, see there.

Details

The multi-exponential fitting problem is solved here with with a separable nonlinear least-squares approach. If the following function is to be fitted,

y = a_0 + a_1 e^{b_1 x} + \ldots + a_n e^{b_n x}

it will be looked at as a nonlinear optimization problem of the coefficients b_i alone. Given the b_i, coefficients a_i are uniquely determined as solution of an (overdetermined) system of linear equations.

This approach reduces the dimension of the search space by half and improves numerical stability and accuracy. As a convex problem, the solution is unique and global.

To solve the nonlinear part, the function lsqnonlin that uses the Levenberg-Marquard algorithm will be applied.

Value

mexpfit returns a list with the following elements:

  • a0: the absolute term, 0 if const is false.

  • a: linear coefficients.

  • b: coefficient in the exponential functions.

  • ssq: the sum of squares for the final fitting.

  • iter: number of iterations resp. function calls.

  • errmess: an error or info message.

Note

As the Jacobian for this expression is known, a more specialized approch would be possible, without using lsqnonlin; see the immoptibox of H. B. Nielsen, Techn. University of Denmark.

Author(s)

HwB email: <hwborchers@googlemail.com>

References

Madsen, K., and H. B. Nielsen (2010). Introduction to Optimization and Data Fitting. Technical University of Denmark, Intitute of Computer Science and Mathematical Modelling.

Nielsen, H. B. (2000). Separable Nonlinear Least Squares. IMM, DTU, Report IMM-REP-2000-01.

See Also

lsqsep, lsqnonlin

Examples

#   Lanczos1 data (artificial data)
#   f(x) = 0.0951*exp(-x) + 0.8607*exp(-3*x) + 1.5576*exp(-5*x)
x <- linspace(0, 1.15, 24)
y <- c(2.51340000, 2.04433337, 1.66840444, 1.36641802, 1.12323249, 0.92688972,
       0.76793386, 0.63887755, 0.53378353, 0.44793636, 0.37758479, 0.31973932,
       0.27201308, 0.23249655, 0.19965895, 0.17227041, 0.14934057, 0.13007002,
       0.11381193, 0.10004156, 0.08833209, 0.07833544, 0.06976694, 0.06239313)
p0 <- c(-0.3, -5.5, -7.6)
mexpfit(x, y, p0, const = FALSE)
## $a0
## [1] 0
## $a
## [1] 0.09510431 0.86071171 1.55758398
## $b
## [1] -1.000022 -3.000028 -5.000009
## $ssq
## [1] 1.936163e-16
## $iter
## [1] 26
## $errmess
## [1] "Stopped by small gradient."

pracma documentation built on Nov. 10, 2023, 1:14 a.m.