This page hammers the soft-thresholding operator from the parent note
S λ ( z ) = sign ( z ) max ( ∣ z ∣ − λ , 0 )
against every kind of input it can receive. Read the parent L1 (Lasso) regularization first if the symbols z (the OLS coefficient before penalty), λ (penalty strength), and ∥ w ∥ 1 are new to you — here we assume you know them and we grind through cases.
Intuition What "every scenario" means here
S λ takes a single number z and a single knob λ ≥ 0 . The only things that can vary are the sign of z , the size of z relative to λ , and the special edge values (z = 0 , ∣ z ∣ = λ exactly, λ = 0 , λ → ∞ ). Enumerate those and you have covered the entire operator.
Every cell below is a distinct behaviour of Lasso. The worked examples that follow are tagged with the cell they hit.
#
Cell (case class)
Trigger condition
Expected behaviour
C1
Positive, large
z > λ > 0
shrink down: w = z − λ > 0
C2
Negative, large
z < − λ
shrink up: w = z + λ < 0
C3
Inside the band
− λ ≤ z ≤ λ
clamp to exactly 0
C4
Boundary knife-edge
$
z
C5
Zero input
z = 0
stays 0 for any λ
C6
No penalty
λ = 0
recovers OLS: w = z
C7
Infinite penalty
λ → ∞
all weights → 0 (predict mean)
C8
Vector / feature selection
many z j , one λ
some survive, some deleted
C9
Scaling trap (word problem)
features in different units
wrong features dropped unless standardized
C10
Exam twist
Ridge vs Lasso same z
Ridge never hits 0; Lasso does
We now cover all ten cells .
Intuition Read the amber line
The grey dashed diagonal is OLS (w = z , no penalty). The cyan bent line is S λ ( z ) . Look at the flat amber segment in the middle: for every z between − λ and + λ the output is pinned to 0 — that flat "dead zone" is feature selection. Outside it, the cyan line runs parallel to the diagonal but shifted toward the axis by exactly λ . Every example below is just "which part of this graph is my z standing on?"
z = 3.0 , λ = 0.5
Forecast: Guess before computing — will this weight survive, and if so, will it get bigger or smaller than 3.0 ?
Check the band. Why this step? The three cases of S λ depend entirely on where ∣ z ∣ sits relative to λ . Here ∣ z ∣ = 3.0 > 0.5 = λ , so we are outside the dead zone → the weight survives.
Apply the formula: w = sign ( 3.0 ) ⋅ max ( 3.0 − 0.5 , 0 ) = 1 ⋅ 2.5 = 2.5 . Why this step? Positive z keeps a positive sign; we subtract the "tax" λ from its magnitude.
Answer: w = 2.5 .
Verify: 2.5 is smaller than 3.0 (shrunk toward zero, as regularization must) but still positive (didn't cross zero). Consistent with the cyan line above the dead zone. ✓
z = − 1.2 , λ = 0.5
Forecast: A negative OLS coefficient — does Lasso flip its sign, or keep it negative?
∣ z ∣ = 1.2 > 0.5 = λ → outside the band, survives. Why this step? Same test as C1; the magnitude is what matters for survival, not the sign.
w = sign ( − 1.2 ) ⋅ max ( 1.2 − 0.5 , 0 ) = ( − 1 ) ⋅ 0.7 = − 0.7 . Why this step? sign carries the direction; max ( ∣ z ∣ − λ , 0 ) carries the shrunk magnitude. Lasso never flips a sign — it can only pull toward zero, and it stops at zero.
Answer: w = − 0.7 .
Verify: ∣ − 0.7∣ < ∣ − 1.2∣ (shrunk) and still negative (no sign flip). ✓
z = 0.4 , λ = 0.5
Forecast: The OLS coefficient is nonzero (0.4 ). Will Lasso keep a small positive weight, or drop the feature entirely?
∣ z ∣ = 0.4 < 0.5 = λ → inside the dead zone. Why this step? This is exactly case C3: the penalty "tax" exceeds what the feature is worth.
w = sign ( 0.4 ) max ( 0.4 − 0.5 , 0 ) = 1 ⋅ max ( − 0.1 , 0 ) = 0 . Why this step? max ( negative , 0 ) = 0 ; the max is the clamp that produces an exact zero , deleting the feature.
Answer: w = 0 — feature removed.
Verify: Standing on the flat amber segment of the figure, output must be 0 . ✓ This is the qualitative difference from Ridge (see C10).
z = 0.5 , λ = 0.5
Forecast: Right on the boundary. Does it survive as a tiny weight, or get zeroed?
∣ z ∣ − λ = 0.5 − 0.5 = 0 . Why this step? We evaluate the inner quantity of the max to see which side of the boundary we're on.
w = sign ( 0.5 ) max ( 0 , 0 ) = 0 . Why this step? max ( 0 , 0 ) = 0 , so the boundary belongs to the zeroed region. This is why case C3 was written with ≤ (− λ ≤ z ≤ λ ), inclusive.
Answer: w = 0 .
Verify: The dead zone closes including its endpoints — the cyan line touches zero exactly at z = ± λ before starting to rise. ✓
z = 0 , λ = 2.0
Forecast: OLS already gives 0 . Can any penalty change that?
∣ z ∣ = 0 ≤ λ for every λ ≥ 0 . Why this step? Zero is always inside the band, so this is a permanent C3.
w = sign ( 0 ) max ( 0 − 2.0 , 0 ) = 0 . Why this step? With sign ( 0 ) = 0 and max ( − 2 , 0 ) = 0 , the product is unambiguously 0 .
Answer: w = 0 for any λ .
Verify: A feature OLS ignored can't be revived by shrinkage — regularization only ever removes, never adds. ✓
z = 3.0 but λ = 0
Forecast: Turn the penalty knob to zero. What should Lasso reduce to?
∣ z ∣ = 3.0 > 0 = λ , outside band. Why this step? With λ = 0 the band [ − λ , λ ] collapses to the single point { 0 } , so almost everything survives.
w = sign ( 3.0 ) max ( 3.0 − 0 , 0 ) = 3.0 . Why this step? Subtracting λ = 0 leaves z untouched.
Answer: w = z = 3.0 (exactly OLS).
Verify: The cyan line lies on top of the grey diagonal when λ = 0 — the "sweet spot" limit stated in the parent note. ✓ See Bias-Variance Tradeoff : λ = 0 is minimum bias, maximum variance.
z = [ 3.0 , 0.4 , − 1.2 ] with λ = 3.0
Forecast: A huge penalty. Which of these three survive? (The parent note claims all go to zero — check it precisely.)
Test each: ∣3.0∣ = 3.0 , ∣0.4∣ = 0.4 , ∣ − 1.2∣ = 1.2 , all compared to λ = 3.0 . Why this step? Each coordinate faces the same λ ; survival is per-coordinate.
∣3.0∣ = 3.0 is not > 3.0 → knife-edge → 0 . The other two are already < 3.0 → 0 . Why this step? Even the largest coefficient sits exactly on the boundary here, so C4 zeroes it.
Answer: w = [ 0 , 0 , 0 ] — model predicts the mean.
Verify: As λ grows past every ∣ z j ∣ , all weights collapse; the penalized model outputs only the (unpenalized) bias w 0 . ✓ This is maximum bias / minimum variance.
z = [ 3.0 , 0.4 , − 1.2 ] , λ = 0.5
Forecast: Apply the same knob to all three. How many features remain, and which one is dropped?
Coordinate 1 → C1: sign ( 3.0 ) max ( 3.0 − 0.5 , 0 ) = 2.5 .
Coordinate 2 → C3: sign ( 0.4 ) max ( 0.4 − 0.5 , 0 ) = 0 .
Coordinate 3 → C2: sign ( − 1.2 ) max ( 1.2 − 0.5 , 0 ) = − 0.7 .
Why these steps? With orthonormal features every coordinate is an independent S λ problem (parent-note assumption), so we just reuse C1–C3.
Answer: w = [ 2.5 , 0 , − 0.7 ] — feature 2 eliminated, 2 of 3 survive.
Verify: Sparsity pattern: exactly the small-magnitude feature dropped. This is Feature Selection happening for free; solved in practice by Coordinate Descent applying S λ per coordinate. ✓
Worked example Housing price:
area and distance in different units
A model predicts house price. Feature A = floor area, feature B = distance to station. Suppose the true effect of both is identical in real-world terms, but you measure area in square-metres and distance in metres . After OLS you get z area = 2.0 and z dist = 0.3 purely because the raw distance numbers are large (so their coefficient is small). Use λ = 0.5 .
Forecast: Both features genuinely matter equally — will Lasso keep both?
Unscaled: w area = S 0.5 ( 2.0 ) = 1.5 (survives), w dist = S 0.5 ( 0.3 ) = 0 (dropped! ). Why this step? The L1 tax λ ∣ w j ∣ is the same size for every coefficient , so a feature whose units force a tiny coefficient looks "cheap to drop" even if it's important.
Fix — standardize both features to unit variance. Then equal true effect ⇒ equal ∣ z j ∣ ; say both become z = 1.2 . Now w = S 0.5 ( 1.2 ) = 0.7 for both . Why this step? Standardizing removes the unit artefact so the penalty compares like with like.
Answer: Unscaled drops distance (0 ); scaled keeps both at 0.7 .
Verify: The figure shows the two dead-zone bands are identical width λ , but the unscaled distance-coefficient 0.3 falls inside it while 2.0 escapes — a pure units artefact. Always standardize before Lasso. ✓
z = 0.4 : compare S λ (Lasso) with Ridge shrinkage, λ = 0.5
Forecast: Both regularizers shrink. Only one can output an exact zero. Which, and what does the other give?
Lasso: S 0.5 ( 0.4 ) = 0 (from C3). Why this step? The diamond corner / dead zone clamps it.
Ridge: minimizing 2 1 ( w − z ) 2 + λ w 2 gives w = 1 + 2 λ z = 1 + 2 ( 0.5 ) 0.4 = 2 0.4 = 0.2 . Why this step? Ridge's penalty w 2 is smooth (differentiable) at 0 , so its solution is a proportional shrink — never a clamp.
Answer: Lasso → 0 (feature deleted); Ridge → 0.2 (feature kept, just smaller).
Verify: 0.2 = 0 : Ridge can only reach exactly 0 when z = 0 . This is the whole reason Ridge (L2) Regularization gives dense solutions and Lasso gives sparse ones; blend them with Elastic Net . ✓
Recall Which matrix cell does
z = 0.5 , λ = 0.5 land in, and what is w ?
C4 (knife-edge). max ( 0 , 0 ) = 0 , so w = 0 . The band is inclusive.
Recall Why does the scaling trap (C9) drop an important feature?
The L1 tax λ ∣ w j ∣ is identical for every coefficient, so a feature whose units force a small coefficient looks cheap to zero out. Standardize first.
Recall On the same
z = 0.4 , why does Ridge give 0.2 but Lasso gives 0 ?
Ridge shrinks proportionally (w = z / ( 1 + 2 λ ) , smooth at 0); Lasso has a dead zone (kink) that clamps small z exactly to 0.
Mnemonic The whole page in one line
"Sign survives, magnitude minus lambda, and the middle band is a graveyard."