Invert GMLscripts.com

dl_list_pop_standard_deviation

Wikipedia:

In statistics, the standard deviation (SD) (represented by the Greek letter sigma, σ) is a measure that is used to quantify the amount of variation or dispersion of a set of data values. A low standard deviation indicates that the data points tend to be very close to the mean (also called the expected value) of the set, while a high standard deviation indicates that the data points are spread out over a wider range of values.

$$\sigma{x}=\sqrt{\frac{\Sigma{x^2}-n\bar{x}^2}{n}} \qquad \small \Sigma{x^2}=x_1^2+x_2^2+\cdots+x_n^2 \qquad \bar{x}=\frac{\Sigma{x}}{n} \qquad \Sigma{x}=x_1+x_2+\cdots+x_n$$

ds_list_pop_standard_deviation(id)
Returns the population standard deviation of the values in a given list.
COPY/// ds_list_pop_standard_deviation(id)
//
//  Returns the population standard deviation of the values in a given list.
//
//      id          list data structure, real
//
/// GMLscripts.com/license
{
    var i,j,k,m;
    j = 0;
    k = ds_list_size(argument0);
    for (i=0; i<k; i+=1) j += ds_list_find_value(argument0, i);
    m = j / k;
    j = 0;
    for (i=0; i<k; i+=1) j += sqr(ds_list_find_value(argument0, i) - m);
    return sqrt(j / k);
}

Contributors: xot

GitHub: View · Commits · Blame · Raw