deno.land / x / simplestatistic@v7.7.1 / src / combine_means.js

combine_means.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/** * When combining two lists of values for which one already knows the means, * one does not have to necessary recompute the mean of the combined lists in * linear time. They can instead use this function to compute the combined * mean by providing the mean & number of values of the first list and the mean * & number of values of the second list. * * @since 3.0.0 * @param {number} mean1 mean of the first list * @param {number} n1 number of items in the first list * @param {number} mean2 mean of the second list * @param {number} n2 number of items in the second list * @returns {number} the combined mean * * @example * combineMeans(5, 3, 4, 3); // => 4.5 */function combineMeans(mean1, n1, mean2, n2) { return (mean1 * n1 + mean2 * n2) / (n1 + n2);}
export default combineMeans;
simplestatistic

Version Info

Tagged at
2 years ago