ds_list_geometric_mean
Computes the geometric mean of values in a list.
The geometric mean of a data set \(\{a_1,a_2 , \ldots,a_n\}\) is given by:
$$\large \left(\prod_{i=1}^n a_i \right)^{1/n} = \sqrt[n]{a_1 a_2 \cdots a_n}$$
- ds_list_geometric_mean(list)
- Returns the geometric mean of values in a list.
COPY/// @func ds_list_geometric_mean(list)
///
/// @desc Returns the geometric mean of values in a list.
///
/// @param {list} list list data structure
///
/// @return {real} geometric mean
///
/// GMLscripts.com/license
function ds_list_geometric_mean(list)
{
var n = ds_list_size(list);
if (n == 0) return undefined;
var geo = 1;
for (var i=0; i<n; i++) geo *= ds_list_find_value(list, i);
return power(geo, 1 / n);
}
Contributors: Quimp
GitHub: View · Commits · Blame · Raw