SVD: Get minimum number of singular values...

A command to get the minimum number of singular values (s.v.'s) whose sum, divided by the sum of all singular values, is smaller than the given fraction.

Examples

Given an SVD with four s.v's 10.0, 6.0, 3.0 and 1.0. The sum of the s.v's is 20.0.

    Get minimum number of singular values: 0.5
The returned value would be 1. The first s.v. divided by the sum is 0.5 (= 10.0 / 20.0). For any fraction lower than 0.5 the query would also return 1, because the first s.v. already covers half of the total sum.
    Get minimum number of singular values: 0.8
The returned value would be 2. The sum of first two s.v.'s divided by the sum is 0.8 (= (10.0 + 6.0) / 20.0). For any fraction between 0.5 and 0.8 the query would also return 2.
    Get minimum number of singular values: 0.95
The returned value would be 3. The sum of first three s.v.'s divided by the sum is 0.95 (= (10.0 + 6.0 + 3.0) / 20.0). For any fraction between 0.8 and 0.95 the query would also return 3.
    Get minimum number of singular values: 0.96
The returned value would be 4.
    Get minimum number of singular values: 0.99
The returned value would be 4.

© djmw 20171214