The dimensionality-reduction pipeline — centre the data, build the covariance matrix, find its eigenvectors, project onto them — hands you new coordinates that are no longer correlated with each other. But they still have very different spreads: the coordinate along PC1 varies a lot, the one along PC2 far less.
Whitening adds one last move. Divide each new coordinate by its own standard deviation, so that every direction ends up with variance exactly . The cloud comes out round, with no direction more stretched than any other.
Task: write whiten(points) for 2D data. points is a list of pairs. Return the whitened pair for every point, in the same order, with each number rounded to 4 decimal places.
You may assume there are at least three points, they don't all lie on one straight line, and the two eigenvalues are different — so both are positive, and each has a single eigenvector direction.
Example.
Here , with eigenvalues and . Whatever the input, each output coordinate should come out with mean and variance — a handy check on your own work.
Once your code passes every test, a reference solution shows up here so you can compare it with yours.