blob: 739dc4147f136e2f109410634a30413800921adf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
var sum = require('./sum');
/**
* Computes the mean of the values in `array`.
*
* @static
* @memberOf _
* @category Math
* @param {Array} array The array to iterate over.
* @returns {number} Returns the mean.
* @example
*
* _.mean([4, 2, 8, 6]);
* // => 5
*/
function mean(array) {
return sum(array) / (array ? array.length : 0);
}
module.exports = mean;
|