Stats Extension
Extension: gama.extension.stats
The Stats extension provides a comprehensive collection of 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) |
stddev / standard_deviation | Returns the population standard deviation of all elements |
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 |
stddev(data) | Returns the standard deviation of a data sequence |
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 |
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 |
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 |
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 |