Temporal Models
Time-domain functions for decay and oscillation fitting.
Exponential Decays
CurveFitModels.single_exponential — Function
single_exponential(p, t)Exponential decay function.
Arguments
p: Parameters [A, τ] or [A, τ, y₀]A: Amplitudeτ: Decay time constanty₀: Vertical offset (default: 0.0)
t: Independent variable (time)
\[\begin{aligned} f(t) = A e^{-t/\tau} + y_0 \end{aligned}\]
CurveFitModels.stretched_exponential — Function
stretched_exponential(p, t)Stretched exponential (Kohlrausch-Williams-Watts) decay function.
Arguments
p: Parameters [A, τ, β] or [A, τ, β, y₀]A: Amplitudeτ: Characteristic time constantβ: Stretching exponent (0 < β ≤ 1)y₀: Vertical offset (default: 0.0)
t: Independent variable (time)
\[\begin{aligned} f(t) = A \exp\left(-\left(\frac{t}{\tau}\right)^\beta\right) + y_0 \end{aligned}\]
When β = 1, this reduces to a single exponential decay. When β < 1, the decay is slower than exponential at long times.
CurveFitModels.n_exponentials — Function
n_exponentials(n::Int)Generate a model function for a sum of n exponential decays.
Returns a function model(p, t) where:
p: Parameters [A₁, τ₁, A₂, τ₂, ..., Aₙ, τₙ, y₀]Aᵢ: Amplitude of i-th exponentialτᵢ: Time constant of i-th exponentialy₀: Offset (final parameter)
t: Independent variable (time)
\[f(t) = \sum_{i=1}^{n} A_i e^{-t/\tau_i} + y_0\]
Example
bi_exp = n_exponentials(2)
p0 = [A1, τ1, A2, τ2, offset]
sol = solve(NonlinearCurveFitProblem(bi_exp, p0, t, y))Oscillations
CurveFitModels.sine — Function
sine(p, t)Sinusoidal function.
Arguments
p: Parameters [A, ω, ϕ] or [A, ω, ϕ, y₀]A: Amplitudeω: Angular frequencyϕ: Phasey₀: Vertical offset (default: 0.0)
t: Independent variable (time)
\[\begin{aligned} f(t) = A \sin(\omega t + \phi) + y_0 \end{aligned}\]
CurveFitModels.damped_sine — Function
damped_sine(p, t)Damped sine function (exponentially decaying sinusoid).
Arguments
p: Parameters [A, ω, ϕ, τ] or [A, ω, ϕ, τ, y₀]A: Amplitudeω: Angular frequencyϕ: Phaseτ: Decay time constanty₀: Vertical offset (default: 0.0)
t: Independent variable (time)
\[\begin{aligned} f(t) = A e^{-t/\tau} \sin(\omega t + \phi) + y_0 \end{aligned}\]