Stats Extension
Extension: gama.extension.stats
The Stats extension provides statistical operators for analysis, regression, ANOVA, probability distributions, clustering, and experimental design.
Operators​
Descriptive Statistics​
| Operator | Description |
|---|---|
mean | Returns the arithmetic mean of all numeric elements in the operand |
mean_of(e) | Returns the mean of expression e evaluated on each element of a collection |
median | Returns the median value of all elements (supports numbers, points, colors) |
standard_deviation(data) | Returns the population standard deviation of the numeric elements of a container |
variance | Returns the variance from a container, a list, or from size/mean/stddev |
variance_of(e) | Returns the variance of expression e evaluated on each element |
moment(data, k, c) | Returns the k-th order moment of a data sequence with constant c |
skewness / skew | Returns the skewness (asymmetry) of a list of values |
kurtosis | Returns kurtosis (excess) from a list of values, from moment/stddev, or from size/moments |
mean_deviation | Returns the mean absolute deviation from the mean |
distribution_of(values, nbbars) | Builds a histogram of the values: a map with values (the number of elements of each bar), legend (the [min:max] label of each bar) and parlist (the two parameters used to compute the bars) |
distribution2d_of(valuesx, valuesy, nbbarsx, nbbarsy) | The same histogram for two series of values |
gini(data) | Returns the Gini index measuring inequality in a list of values |
Aggregation (for lists/matrix/maps)​
| Operator | Description |
|---|---|
min | Returns the minimum element (supports numbers, points, containers, files, graphs) |
max | Returns the maximum element (supports numbers, points, containers, files, graphs) |
mul / product | Returns the product of all elements (supports numbers, points, containers, files, graphs, maps) |
min_of(e) | Returns the minimum value of expression e evaluated on each element |
max_of(e) | Returns the maximum value of expression e evaluated on each element |
product_of(e) | Returns the product of expression e evaluated on each element |
frequency_of(e) | Returns a map of frequency counts by evaluating expression e on each element |
Mean Types​
| Operator | Description |
|---|---|
mean | Arithmetic mean |
geometric_mean | Geometric mean |
harmonic_mean | Harmonic mean |
rms | Root-Mean-Square value given size and sum of squares |
Percentiles & Quantiles​
| Operator | Description |
|---|---|
quantile(data, phi) | Returns the phi-quantile value (linear interpolation) |
quantile_inverse(data, element) / percentile | Returns the percentile of an element within a sorted data sequence |
rank_interpolated(data, element) | Returns the linearly interpolated rank of an element within a sorted data sequence |
Splits & Bins​
| Operator | Description |
|---|---|
split(data) | Splits a list into n=(1+3.3*log10(n)) bins automatically |
split_in(data, n) | Splits a list into a specified number of equal-width bins |
split_using(data, stops) | Splits a list using explicit boundary values (stops) |
Rolling Statistics​
| Operator | Description |
|---|---|
rolling_vc(data) | Returns rolling coefficient of variance for increasing observation counts |
rolling_se(data) | Returns rolling standard error for increasing observation counts |
Correlation & Distance​
| Operator | Description |
|---|---|
correlation(x, y) | Returns the Pearson correlation of two data sequences |
spearman_correlation(x, y) | Returns the Spearman's rank correlation of two data sequences |
covariance(x, y) | Returns the covariance of two data sequences |
auto_correlation(data, lag) | Returns the auto-correlation of a data sequence at a given lag |
dtw(x, y) | Returns the Dynamic Time Warping distance between two time series |
dtw(x, y, radius) | DTW with optional Sakoe-Chiba radius constraint |
durbin_watson(residuals) | Returns the Durbin-Watson statistic for autocorrelation in residuals |
Clustering​
| Operator | Description |
|---|---|
kmeans(data, k) | Clusters data using the K-means++ algorithm (k clusters) |
kmeans(data, k, max_iterations) | K-means++ with optional maximum iterations |
dbscan(data, eps, min_samples) | Clusters data using DBSCAN density-based spatial clustering |
simple_clustering_by_distance(agents, distance) / simple_clustering_by_envelope_distance(...) | Groups the agents whose locations are separated by less than distance (in meters), as a list of lists of agents |
hierarchical_clustering(agents, distance) | Builds the same groups as a hierarchy of clusters |
Probability Distributions​
| Operator | Description |
|---|---|
normal_density(x, mean, stddev) / dnorm(x, mean, stddev) | Probability density at x in a normal distribution |
normal_area(x, mean, stddev) / pnorm(x, mean, stddev) | Cumulative area to the left of x in a normal distribution |
normal_inverse(area, mean, stddev) | Returns x given the cumulative area (inverse normal CDF) |
student_area(x, df) | Cumulative area to the left of x in a Student T distribution |
student_t_inverse(area, df) | Returns t such that area from -infinity to t equals the given probability |
chi_square(x, df) / pchisq(x, df) | Area under the left tail of the Chi-square PDF |
chi_square_complemented(x, df) | Area under the right tail of the Chi-square PDF |
gamma(x) | Value of the Gamma function at x |
log_gamma / lgamma(x) | Natural log of the Gamma function value at x |
gamma_distribution(x, shape, scale) / pgamma | Cumulative gamma distribution (integral from 0 to x) |
gamma_distribution_complemented(x, shape, scale) | Complemented cumulative gamma distribution |
incomplete_beta(a, b, x) | Regularized incomplete beta function from 0 to x |
incomplete_gamma(a, x) | Regularized incomplete Gamma function up to x |
incomplete_gamma_complement(a, x) | Complemented regularized incomplete Gamma function |
beta(a, b) | Beta function value for arguments a and b |
binomial_coeff(n, k) | Binomial coefficient "n choose k" (as double) |
binomial_sum(k, n, p) / pbinom | Cumulative binomial probability (terms 0 through k) |
binomial_complemented(k, n, p) | Sum of binomial density terms from k+1 to n |
pValue_for_tStat(t, df) | Two-tailed P value of a t statistic |
pValue_for_fStat(f, dfn, dfd) | P value of an F statistic with numerator/denominator degrees of freedom |
power_test(effect_size, alpha, beta) | Returns the minimum sample size needed to satisfy a power test |
Regression​
| Operator | Description |
|---|---|
build(x, regression_type) | Builds a regression model from matrix data (first column = Y) |
glm(x, regression_type) | Builds a Generalized Linear Model using OLS |
predict(model, x) | Returns the predicted value from a regression model for a given instance |
rSquare(model) | Returns the adjusted R-squared value for a regression model |
residuals(model) | Returns the list of residuals from a regression model |
t_test(x, y) | Returns the p-value of a two-sample two-tailed t-test comparing means |
rolling_se(data) | Returns rolling standard error for increasing observation counts |
rolling_vc(data) | Returns rolling coefficient of variance for increasing observation counts |
ANOVA​
| Operator | Description |
|---|---|
anova(groups, type) | Performs a one-way ANOVA test on a list of groups of numerical data. Returns a map with ANOVA results (F value, p value, etc.). type: "standard" for Type I Sum of Squares (default), type: "orthogonal" for Type III Sum of Squares (orthogonal to order) |
anova(groups) | Performs a one-way ANOVA test on a list of groups of data. Each group is a list of numbers. Returns a map with ANOVA results (F value, p value, etc.) |
multi_anova(response, factor1, factor2, type) | Performs a two-way ANOVA with interactions on a response variable and two factors. Uses Type III Sum of Squares (orthogonal to order) by default |
Independence Tests​
| Operator | Description |
|---|---|
hsic(x, y) | Computes the normalized Hilbert-Schmidt Independence Criterion between two variables (returns 0-1) |
hsic_p_value(x, y, n_permutations) | Computes the p-value for the HSIC independence test using permutation testing |
Spatial Statistics​
The operators of this group are the ones GAMA declares in the spatial category: they work on geometries or on the locations of agents, not on bare lists of numbers.
| Operator | Description |
|---|---|
moran(vals, weightMatrix) | Moran index of a list of values, with the matrix of weights that describes their neighborhood |
k_nearest_neighbors(agent, agents, k) | The k agents of the map agents nearest the given agent, ranked by the distance between their locations |
IDW(geometries, points, power) / inverse_distance_weighting(...) | Interpolates the values of the points over the geometries by inverse distance weighting; returns a map from geometry to float |
Comparison of Two Maps​
These operators take the values of two rasters (or of two simulations) as lists of the same length and return an index. They are illustrated by Exploration Methods.
| Operator | Description |
|---|---|
kappa(vals1, vals2, categories) | Cohen's kappa between two lists of values, restricted to the given categories |
kappa_sim(valsInit, valsObs, valsSim, categories) | The same index between an observed map and a map simulated from a common initial state |
fuzzy_kappa(agents, vals1, vals2, similarities, categories, fuzzyCategories, distance) | Kappa computed on membership values, for fuzzy classifications |
fuzzy_kappa_sim(agents, valsInit, valsObs, valsSim, similarities, categories, fuzzyTransitions, distance) | The same for a simulated map |
percent_absolute_deviation(valsObserved, valsSimulated) | Percent absolute deviation between an observed and a simulated series |
Sampling​
| Operator | Description |
|---|---|
sobol_analysis(file/agent, parameters, n, outputs) | Returns a report string containing Sobol sensitivity indices analysis results and saves to file |
morris_analysis(agent, parameters, n, group_number, outputs) | Returns a report string containing Morris (Elementary Effects) sensitivity analysis results |
stochanalysis(replicat, threshold, data, nb_parameters) | Stochasticity analysis of the data (a file, a map or a matrix of results), returned as a readable string |
Runnable models​
The extension ships the following projects, visible in the Models navigator by category:
| Category | Project | Models |
|---|---|---|
| Recipes | Statistics | Statistic Operators.gaml, Regression.gaml |
| Recipes | Clustering Algorithms | Clustering.gaml, Spatial Clustering.gaml |
| Recipes | Spatial Statistics | models/Raster Map Comparison.gaml, models/Vector Map Comparison.gaml |
| Tests | Statistical Tests | models/StatsOperatorsTest.gaml, models/Sensitivity Tools Tests.gaml, models/HSICRobustnessTest.gaml, models/StatsInputRobustnessTest.gaml |
Statistic Operators.gaml exercises most of the tables above and is the fastest way to see what an operator returns.