Step 02Question 2 · estimation
Unmixing the signal, four ways
Knowing the time courses, can we recover where each source lives in the image, and then rebuild its time course from the data? Switch between the estimators, move the penalty, and watch the maps sharpen or fall apart.
Using the 2021 parameters. Results match the report.
Because we generated the data, the regressors are known: . Least squares then retrieves every spatial map in one closed-form step, and the time courses follow by projecting the data back onto those maps:
The maps come back recognisable but speckled, because every pixel's noise is fitted as faithfully as its signal.
Least squares has no tuning parameter. It is the unbiased baseline every other method is compared with.
- Σ cT (time courses)
- 5.2674
- 2021 report: 5.2674
- Σ cS (spatial maps)
- 1.1486
Figure 2.1
Retrieved sources: Least squares
- Ground truth
- Retrieved (LSR)
time courses shown as z-scores
Source 1
cS 0.53
cT 0.886
Source 2
cS 0.00
cT 0.877
Source 3
cS 0.02
cT 0.892
Source 4
cS 0.05
cT 0.867
Source 5
cS 0.00
cT 0.879
Source 6
cS 0.55
cT 0.865
reshape(21, 21).T), and the true time course with the retrieved column of D = XAᵀ. cT and cS are the absolute correlations the assignment asks for. The spatial scores depend on the pixel ordering; see the note at the bottom of the page.Figure 2.2
Correlation vectors for all four estimators
- LSR
- RR
- LR
- PCR
cT: time courses
cS: spatial maps (as submitted)
Scroll sideways for S1–S6.
| Method | Vector | S1 | S2 | S3 | S4 | S5 | S6 | Sum |
|---|---|---|---|---|---|---|---|---|
| LSR | cT | 0.886 | 0.877 | 0.892 | 0.867 | 0.879 | 0.865 | 5.2674 |
| cS | 0.531 | 0.003 | 0.019 | 0.045 | 0.001 | 0.549 | 1.1486 | |
| RR | cT | 0.886 | 0.877 | 0.892 | 0.868 | 0.881 | 0.867 | 5.2713 |
| cS | 0.531 | 0.003 | 0.019 | 0.045 | 0.001 | 0.549 | 1.1487 | |
| LR | cT | 0.896 | 0.881 | 0.900 | 0.903 | 0.930 | 0.918 | 5.4275 |
| cS | 0.883 | 0.052 | 0.079 | 0.038 | 0.059 | 0.697 | 1.8078 | |
| PCR | cT | 0.077 | 0.187 | 0.044 | 0.028 | 0.022 | 0.004 | 0.3624 |
| cS | 0.050 | 0.112 | 0.054 | 0.099 | 0.192 | 0.260 | 0.7675 |
Figure 2.3
Why pixel 30 tracks the third source, not the fourth
Fidelity notes
What the port keeps from 2021, quirks included
The aim here is to reproduce what I submitted, not to correct it, so the TypeScript port keeps a few behaviours of the original code. The parity tests check each of them against the notebook's saved outputs.
- Ridge λ is not scaled by V. The task suggests , but the notebook added
0.5 * np.eye(6)directly. The slider uses the same convention. - The lasso is a single thresholded gradient step. The original
LassoRegressionrestarts every iteration from a zero vector, so its ten repetitions all return the same update. It also scales survivors by(1 / 1 + thr), which Python reads as 1 + thr. Both are reproduced exactly. - Spatial scores and pixel order. X was built from maps flattened column by column, but Q2.4 re-read the maps from a CSV flattened row by row, then correlated them with the retrieved maps. Under the As submitted toggle you get that comparison and the reported sums (ΣcSLR = 1.808, ΣcSRR = 1.149). Under Aligned both use the same order and the spatial scores rise, while the lasso still beats ridge.
Next · Step 03
Tune
Pick the lasso penalty ρ from the mean MSE over noisy realisations, then see how sure that choice is.