(arrValues: number[], arrWeights: number[])
| 112 | * @ignore |
| 113 | */ |
| 114 | export function weightedAvg(arrValues: number[], arrWeights: number[]): number { |
| 115 | const result = arrValues |
| 116 | .map((value, i) => { |
| 117 | const weight = arrWeights[i]; |
| 118 | const sum = value * weight; |
| 119 | |
| 120 | return [sum, weight]; |
| 121 | }) |
| 122 | .reduce((p, c) => [p[0] + c[0], p[1] + c[1]], [0, 0]); |
| 123 | |
| 124 | return result[0] / result[1]; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Returns a `Promise` that resolves after a specific period of time. This is useful to implement waiting |
no test coverage detected
searching dependent graphs…