tv_denoise
result = tv_denoise(y, [lambda=1.0])
Input: y, lambda · Output: result
What it is
Total-variation denoising: y is a length-N number vector; lambda is an optional positional number, the smoothing penalty, default 1.0 — larger values remove more variation. Assumes few CHANGES rather than few non-zeros, so a step survives where an l1 method would flatten it. Condat's direct algorithm, one pass.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = tv_denoise(y, [lambda=1.0]) | y number or vectorTotal-variation denoising: y is a length-N number vector.lambda number, optional (default 1.0)lambda is an optional positional number, the smoothing penalty, default 1.0 — larger values remove more variation. | result vector | Returns a length-N vector. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
clean = zeros(200)
for i in 60 to 129
clean[i] = 1.0
end for
noisy = clean + 0.15 * randn(200, seed = 3)
tv = tv_denoise(noisy, 0.3)
print("total variation {sum(abs(diff(noisy))):.1f} -> {sum(abs(diff(tv))):.1f}")
total variation 36.5 -> 2.5
from compressed-sensing
How it works
tv_denoise(y, lambda) — total variation. A different sparsity assumption: few CHANGES rather than few non-zeros, so a step survives where an l1 method would flatten it.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.