src/utils.js
// maxWidth: max number of bins / strips
max number of bins / strips
max number of bins / strips
function compressFeatureValues(values, maxNumStrips, sort = false) {
    const sortedVal = sort ? values.slice().sort((a, b) => b - a) : values;
    const n = values.length;
    const r = Math.ceil(n / maxNumStrips);
    const compValues = [];
    for (let i = 0; i < n; i += r) {
        let t = 0;
        for (let j = 0; j < r && i + j < n; j++) {
            t = Math.max(t, sortedVal[i + j]); 
        }
        compValues.push(t);
    }
    return compValues;
}
function compressFeatureValues ( values , maxNumStrips , sort = false ) { const sortedVal = sort ? values . slice ( ) . sort ( ( a , b ) => b - a ) : values ; const n = values . length ; const r = Math . ceil ( n / maxNumStrips ) ; const compValues = [ ] ; for ( let i = 0 ; i < n ; i += r ) { let t = 0 ; for ( let j = 0 ; j < r && i + j < n ; j ++ ) { t = Math . max ( t , sortedVal [ i + j ] ) ; } compValues . push ( t ) ; } return compValues ; }
maxWidth: max number of bins / strips
maxWidth : max number of bins / strips
// Compression ratio // console.log("feature compress rate = ", r); // Use the max function to aggreagte