rlkk_validate
Builtin index · Signal processing
result = rlkk_validate(Z, freqs, [lambda=1e-3], [threshold=2.0])
Input: Z, freqs, lambda, threshold · Output: result
What it is
Z: a length-N complex vector (CVec); freqs: a length-N real vector (Hz); lambda (optional number); threshold (optional number, percent).
Overloads
One call shape — this function is not overloaded.
Code Input Output Description
result = rlkk_validate(Z, freqs, [lambda=1e-3], [threshold=2.0])Z vector or CVec Z: a length-N complex vector (CVec).
freqs vector freqs: a length-N real vector (Hz).
lambda number, optional (default 1e-3) lambda (optional number).
threshold number, optional (default 2.0) threshold (optional number, percent).
Model — kind "rlkk_validation"
valid boolean a boolean, true iff every point's percent residual is under threshold
residuals vector a length-N real vector, percent
max_residual number a number
Returns a Model (kind "rlkk_validation") with fields valid (a boolean, true iff every point's percent residual is under threshold), residuals (a length-N real vector, percent), max_residual (a number). Checks Z against its own rLKK reconstruction.
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
Z = [100 - 20i , 80 - 45i , 50 - 55i , 30 - 35i , 22 - 12i ] # measured impedance
freqs = [0.1 , 1 , 10 , 100 , 1000 ] # Hz
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 ("consistent within {v.max_residual:.2f}%" )
else
print ("bad points: {where(abs(v.residuals) > 2.0)}" )
end if
output consistent within 0.00% from specialized
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}%" )
else
print ("bad points: {where(abs(v.residuals) > 2.0)}" )
end
nyquist (Z) # Re(Z) vs -Im(Z), the standard EIS view
output measurement is causal/linear/stable within 0.013416%
-200
-100
0
100
200
300
400
500
-200
0
200
400
600
800
x=0.21, y=0
x=0.21, y=0
x=0.21, y=0
x=0.21, y=0
x=0.21, y=0
x=0.21, y=0
x=0.21, y=$10^{-9}$
x=0.21, y=$1.1\times10^{-9}$
x=0.21, y=$1.2\times10^{-9}$
x=0.21, y=$1.3\times10^{-9}$
x=0.21, y=$1.4\times10^{-9}$
x=0.21, y=$1.5\times10^{-9}$
x=0.21, y=$1.7\times10^{-9}$
x=0.21, y=$1.8\times10^{-9}$
x=0.21, y=$2\times10^{-9}$
x=0.21, y=$2.1\times10^{-9}$
x=0.21, y=$2.3\times10^{-9}$
x=0.21, y=$2.5\times10^{-9}$
x=0.21, y=$2.7\times10^{-9}$
x=0.21, y=$2.9\times10^{-9}$
x=0.21, y=$3.2\times10^{-9}$
x=0.21, y=$3.4\times10^{-9}$
x=0.21, y=$3.7\times10^{-9}$
x=0.21, y=$4\times10^{-9}$
x=0.21, y=$4.4\times10^{-9}$
x=0.21, y=$4.8\times10^{-9}$
x=0.21, y=$5.2\times10^{-9}$
x=0.21, y=$5.6\times10^{-9}$
x=0.21, y=$6.1\times10^{-9}$
x=0.21, y=$6.6\times10^{-9}$
x=0.21, y=$7.1\times10^{-9}$
x=0.21, y=$7.7\times10^{-9}$
x=0.21, y=$8.4\times10^{-9}$
x=0.21, y=$9.1\times10^{-9}$
x=0.21, y=$9.9\times10^{-9}$
x=0.21, y=$1.1\times10^{-8}$
x=0.21, y=$1.2\times10^{-8}$
x=0.21, y=$1.3\times10^{-8}$
x=0.21, y=$1.4\times10^{-8}$
x=0.21, y=$1.5\times10^{-8}$
x=0.21, y=$1.6\times10^{-8}$
x=0.21, y=$1.7\times10^{-8}$
x=0.21, y=$1.9\times10^{-8}$
x=0.21, y=$2\times10^{-8}$
x=0.21, y=$2.2\times10^{-8}$
x=0.21, y=$2.4\times10^{-8}$
x=0.21, y=$2.6\times10^{-8}$
x=0.21, y=$2.8\times10^{-8}$
x=0.21, y=$3.1\times10^{-8}$
x=0.21, y=$3.3\times10^{-8}$
x=0.21, y=$3.6\times10^{-8}$
x=0.21, y=$3.9\times10^{-8}$
x=0.21, y=$4.2\times10^{-8}$
x=0.21, y=$4.6\times10^{-8}$
x=0.21, y=$5\times10^{-8}$
x=0.21, y=$5.4\times10^{-8}$
x=0.21, y=$5.9\times10^{-8}$
x=0.21, y=$6.4\times10^{-8}$
x=0.21, y=$6.9\times10^{-8}$
x=0.21, y=$7.5\times10^{-8}$
x=0.21, y=$8.1\times10^{-8}$
x=0.21, y=$8.8\times10^{-8}$
x=0.21, y=$9.5\times10^{-8}$
x=0.21, y=$10^{-7}$
x=0.21, y=$1.1\times10^{-7}$
x=0.21, y=$1.2\times10^{-7}$
x=0.21, y=$1.3\times10^{-7}$
x=0.21, y=$1.4\times10^{-7}$
x=0.21, y=$1.5\times10^{-7}$
x=0.21, y=$1.7\times10^{-7}$
x=0.21, y=$1.8\times10^{-7}$
x=0.21, y=$2\times10^{-7}$
x=0.21, y=$2.1\times10^{-7}$
x=0.21, y=$2.3\times10^{-7}$
x=0.21, y=$2.5\times10^{-7}$
x=0.21, y=$2.7\times10^{-7}$
x=0.21, y=$3\times10^{-7}$
x=0.21, y=$3.2\times10^{-7}$
x=0.21, y=$3.5\times10^{-7}$
x=0.21, y=$3.8\times10^{-7}$
x=0.21, y=$4.1\times10^{-7}$
x=0.21, y=$4.4\times10^{-7}$
x=0.21, y=$4.8\times10^{-7}$
x=0.21, y=$5.2\times10^{-7}$
x=0.21, y=$5.7\times10^{-7}$
x=0.21, y=$6.1\times10^{-7}$
x=0.21, y=$6.7\times10^{-7}$
x=0.21, y=$7.2\times10^{-7}$
x=0.21, y=$7.8\times10^{-7}$
x=0.21, y=$8.5\times10^{-7}$
x=0.21, y=$9.2\times10^{-7}$
x=0.21, y=$10^{-6}$
x=0.21, y=$1.1\times10^{-6}$
x=0.21, y=$1.2\times10^{-6}$
x=0.21, y=$1.3\times10^{-6}$
x=0.21, y=$1.4\times10^{-6}$
x=0.21, y=$1.5\times10^{-6}$
x=0.21, y=$1.6\times10^{-6}$
x=0.21, y=$1.8\times10^{-6}$
x=0.21, y=$1.9\times10^{-6}$
x=0.21, y=$2.1\times10^{-6}$
x=0.21, y=$2.2\times10^{-6}$
x=0.21, y=$2.4\times10^{-6}$
x=0.21, y=$2.6\times10^{-6}$
x=0.21, y=$2.9\times10^{-6}$
x=0.21, y=$3.1\times10^{-6}$
x=0.21, y=$3.4\times10^{-6}$
x=0.21, y=$3.6\times10^{-6}$
x=0.21, y=$4\times10^{-6}$
x=0.21, y=$4.3\times10^{-6}$
x=0.21, y=$4.7\times10^{-6}$
x=0.21, y=$5\times10^{-6}$
x=0.21, y=$5.5\times10^{-6}$
x=0.21, y=$5.9\times10^{-6}$
x=0.21, y=$6.4\times10^{-6}$
x=0.21, y=$7\times10^{-6}$
x=0.21, y=$7.6\times10^{-6}$
x=0.21, y=$8.2\times10^{-6}$
x=0.21, y=$8.9\times10^{-6}$
x=0.21, y=$9.6\times10^{-6}$
x=0.21, y=$10^{-5}$
x=0.21, y=$1.1\times10^{-5}$
x=0.21, y=$1.2\times10^{-5}$
x=0.21, y=$1.3\times10^{-5}$
x=0.21, y=$1.4\times10^{-5}$
x=0.21, y=$1.6\times10^{-5}$
x=0.21, y=$1.7\times10^{-5}$
x=0.21, y=$1.8\times10^{-5}$
x=0.21, y=$2\times10^{-5}$
x=0.21, y=$2.2\times10^{-5}$
x=0.21, y=$2.3\times10^{-5}$
x=0.21, y=$2.5\times10^{-5}$
x=0.21, y=$2.8\times10^{-5}$
x=0.21, y=$3\times10^{-5}$
x=0.21, y=$3.2\times10^{-5}$
x=0.21, y=$3.5\times10^{-5}$
x=0.21, y=$3.8\times10^{-5}$
x=0.21, y=$4.1\times10^{-5}$
x=0.21, y=$4.5\times10^{-5}$
x=0.21, y=$4.9\times10^{-5}$
x=0.21, y=$5.3\times10^{-5}$
x=0.21, y=$5.7\times10^{-5}$
x=0.21, y=$6.2\times10^{-5}$
x=0.21, y=$6.7\times10^{-5}$
x=0.21, y=$7.3\times10^{-5}$
x=0.21, y=$7.9\times10^{-5}$
x=0.21, y=$8.6\times10^{-5}$
x=0.21, y=$9.3\times10^{-5}$
x=0.21, y=$10^{-4}$
x=0.21, y=$1.1\times10^{-4}$
x=0.21, y=$1.2\times10^{-4}$
x=0.21, y=$1.3\times10^{-4}$
x=0.21, y=$1.4\times10^{-4}$
x=0.21, y=$1.5\times10^{-4}$
x=0.21, y=$1.6\times10^{-4}$
x=0.21, y=$1.8\times10^{-4}$
x=0.21, y=$1.9\times10^{-4}$
x=0.21, y=$2.1\times10^{-4}$
x=0.21, y=$2.3\times10^{-4}$
x=0.21, y=$2.5\times10^{-4}$
x=0.21, y=$2.7\times10^{-4}$
x=0.21, y=$2.9\times10^{-4}$
x=0.21, y=$3.1\times10^{-4}$
x=0.21, y=$3.4\times10^{-4}$
x=0.21, y=$3.7\times10^{-4}$
x=0.21, y=$4\times10^{-4}$
x=0.21, y=$4.3\times10^{-4}$
x=0.21, y=$4.7\times10^{-4}$
x=0.21, y=$5.1\times10^{-4}$
x=0.21, y=$5.5\times10^{-4}$
x=0.21, y=$6\times10^{-4}$
x=0.21, y=$6.5\times10^{-4}$
x=0.21, y=$7\times10^{-4}$
x=0.21, y=$7.6\times10^{-4}$
x=0.21, y=$8.2\times10^{-4}$
x=0.21, y=$8.9\times10^{-4}$
x=0.21, y=$9.7\times10^{-4}$
x=0.21, y=0.001
x=0.21, y=0.001
x=0.21, y=0.001
x=0.21, y=0.001
x=0.21, y=0.001
x=0.21, y=0.002
x=0.21, y=0.002
x=0.21, y=0.002
x=0.21, y=0.002
x=0.21, y=0.002
x=0.209, y=0.002
x=0.209, y=0.002
x=0.209, y=0.003
x=0.209, y=0.003
x=0.209, y=0.003
x=0.209, y=0.003
x=0.209, y=0.003
x=0.209, y=0.004
x=0.208, y=0.004
x=0.208, y=0.004
x=0.208, y=0.004
x=0.207, y=0.004
x=0.207, y=0.005
x=100, y=0.063
x=100, y=0.102
x=100, y=0.166
x=99.999, y=0.269
x=99.998, y=0.437
x=99.995, y=0.709
x=99.987, y=1.152
x=99.965, y=1.869
x=99.908, y=3.034
x=99.757, y=4.919
x=99.363, y=7.956
x=98.338, y=12.785
x=95.734, y=20.21
x=89.485, y=30.674
x=76.347, y=42.495
x=55.04, y=49.745
x=31.708, y=46.534
x=14.973, y=35.68
x=6.261, y=24.225
x=2.47, y=15.522
Two stationary tones
time (s)
frequency (Hz)
from signal-processing
How it works
rlkk_validate(Z, freqs, [lambda=1e-3], [threshold=2.0]) — checks Z against its own rLKK reconstruction; valid is true when every point's residual is under threshold percent. Model kind "rlkk_validation", fields valid/ residuals/max_residual.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.