pflm.fpca.utils.select_num_pcs_fve#

select_num_pcs_fve(eig_lambda: ndarray, fve_threshold: float, max_components: int = 20)[source][source]#

Select the number of principal components based on cumulative explained variance.

Parameters:
eig_lambdanp.ndarray of shape (k,)

Non-negative eigenvalues.

fve_thresholdfloat

Target fraction of variance explained (typically in (0, 1]).

max_componentsint, default=20

Upper bound on the number of components considered.

Returns:
cumulative_fvenp.ndarray of shape (k,)

Cumulative explained variance curve.

num_pcsint

Number of components needed to reach the threshold, clipped by max_components.

Notes

Assumes eig_lambda sums to a positive value; otherwise the result is undefined.