/**
 * 加权平均数
 */ param { Array < number > } numberData param { Array < number > } weigth function weigthVariance ( [ ... numberData ] , [ ... weigth ] ) { let totalWigth = 0 , totaNumber = 0 ; if ( numberData . length == weigth . length ) { for ( let i = 0 ; i <= numberData . length ; i ++ ) { totalWigth += weigth [ i ] ; totaNumber += numberData [ i ] * weigth [ i ] ; } } else { throw Error ( "权重值和数据不匹配!" ) ; } return totaNumber / totalWigth ; } export { weigthVariance } ;