NumPy allowed · plain Python earns 10 bonus points
Implement the real quantity behind every PCA "scree plot" and "how many components do I need to keep 95% of the variance?" decision -- computed from first principles via covariance-matrix eigendecomposition, the same route sklearn's PCA takes internally for dense data.
Implement pca_explained_variance_ratio(X, k): mean-center X, form its (d x d) covariance matrix, eigendecompose it with np.linalg.eigh, sort eigenvalues descending, and return the top-k eigenvalues divided by the sum of all eigenvalues.
pca_explained_variance_ratio(X: list[list[float]], k: int) -> list[float]