Implement components_for_variance(X, threshold): centre X, compute the explained-variance ratio of each principal component (via SVD), and return the smallest number of components whose cumulative ratio is at least threshold.
Also implement explained_variance_ratio(X) returning the full ratio array (sorted descending, summing to 1).