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_cv

This script returns the coefficient of variation (CV) for the values in a given list.

Wikipedia:

The coefficient of variation (CV) is defined as the ratio of the standard deviation σ to the mean μ :

cv=σμ

It shows the extent of variability in relation to the mean of the population.

ds_list_cv(id[,sample])
Returns the coefficient of variation for the values in a given list.
COPY
  1. /// ds_list_cv(id[,sample])
  2. //
  3. // Returns the coefficient of variation for the values in a given list.
  4. //
  5. // id list data structure, real
  6. // sample true if the list is made up of a sample, bool
  7. //
  8. /// gmlscripts.pro/license
  9. {
  10. var n, avg, sum, i;
  11. n = ds_list_size(argument0);
  12. avg = 0;
  13. sum = 0;
  14.  
  15. for (i=0; i<n; i+=1) avg += ds_list_find_value(argument0, i);
  16. avg /= n;
  17. for (i=0; i<n; i+=1) sum += sqr(ds_list_find_value(argument0, i) - avg);
  18.  
  19. return sqrt(sum/(n - argument1))/avg;
  20. }

Contributors: Quimp

GitHub: View · Commits · Blame · Raw