mass_filter
mass_filter.Rd
Filter Vector Elements by Cumulative Mass Threshold
Arguments
- mass
A numeric vector of values (e.g., weights, similarities, or densities).
- thresh
Numeric. Proportion of total cumulative mass to retain (default: 0.9).
Details
Retains the top elements in a numeric vector based on cumulative mass. Elements contributing least to the total are zeroed out until the specified proportion of total mass (`thresh`) is retained.
This function normalizes the input to sum to 1, ranks the elements by size, and sets to zero those contributing below the cutoff needed to achieve `thresh` cumulative mass. Useful for sparsifying matrices.