You are currently viewing the gmlscripts.pro static mirror. Forum access and script submissions are not available through this mirror.

Invert gmlscripts.pro

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(id)
Returns the geometric mean of the values in a given list.
COPY/// ds_list_geometric_mean(id)
//
//  Returns the geometric mean of the values in a given list.
//
//      id          list data structure, real
//
/// gmlscripts.pro/license
{
    var n, geo, i;
    n = ds_list_size(argument0);
    geo = 1;

    for (i=0; i<n; i+=1) geo *= ds_list_find_value(argument0, i);

    return power(geo, 1/n);
}

Contributors: Quimp

GitHub: View · Commits · Blame · Raw