result = rlkk_reconstruct(Z, freqs, [lambda=1e-4], [fx=])
Input: Z, freqs, lambda, fx · Output: result
What it is
Z: a length-N complex vector (CVec); freqs: a length-N real vector (Hz); lambda (optional number): regularization strength, larger tolerates noisier data at the cost of fitting detail; fx (optional length-M real vector, Hz): overrides the default DRT frequency grid (logspace(-8, 8, 160), i.e. M=160).
Overloads
One call shape — this function is not overloaded.
Code
Input
Output
Description
result = rlkk_reconstruct(Z, freqs, [lambda=1e-4], [fx=])
Zvector or CVecZ: a length-N complex vector (CVec).
freqsvectorfreqs: a length-N real vector (Hz).
lambdanumber, optional (default 1e-4)lambda (optional number): regularization strength, larger tolerates noisier data at the cost of fitting detail.
fxvector, optionalfx (optional length-M real vector, Hz): overrides the default DRT frequency grid (logspace(-8, 8, 160), i.e.
Model—kind "rlkk"
zCVeca length-N CVec, the reconstructed spectrum
gammavectora length-M real vector, the fitted DRT coefficients
Returns a Model (kind "rlkk") with fields z (a length-N CVec, the reconstructed spectrum) and gamma (a length-M real vector, the fitted DRT coefficients). Fits the regularized Distribution of Relaxation Times (DRT) and reconstructs Z from it.
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
freqs = logspace(0, 4, 20)
R = 100
C = 1e-6
w = 2 * pi * freqs
Z = R / (1 + 1j * w * R * C) # a simple RC impedance, as measured data
fit = rlkk_reconstruct(Z, freqs, lambda=1e-4) # fit.z, fit.gamma
v = rlkk_validate(Z, freqs, lambda=1e-3, threshold=2.0)
if v.valid
print("measurement is causal/linear/stable within {v.max_residual}%")
elseprint("bad points: {where(abs(v.residuals) > 2.0)}")
endnyquist(Z) # Re(Z) vs -Im(Z), the standard EIS view
output
measurement is causal/linear/stable within 0.013416%
(rLKK) validation/reconstruction, a port of Ahmed Yousef Kallel's own published method (Kallel & Kanoun, "Regularized linear Kramers-Kronig transform for consistency check of noisy impedance spectra with logarithmic frequency distribution", IWIS 2021) — see qu_core::eis for the algorithm. Z is a complex impedance spectrum (a CVec), freqs its frequency vector in Hz. rlkk_reconstruct/ rlkk_validate return a Value::Model (the same named-field multi-return convention as kalman_init/ols_model) since each call's outputs are one related result, not independent ones. rlkk_reconstruct(Z, freqs, [lambda=1e-4], [fx=]) — model kind "rlkk", fields z (the reconstructed spectrum) and gamma (the fitted DRT coefficients).
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.