Skip to content

ExtensionStats

Arthur edited this page Jul 22, 2026 · 1 revision

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

See Also

  1. What's new (Changelog)
  2. Migration Guide (2025-06 → 2026-06)
  1. Installation and Launching
    1. Installation
    2. Launching GAMA
    3. Updating GAMA
    4. Installing Plugins
  2. Workspace, Projects and Models
    1. Navigating in the Workspace
    2. Changing Workspace
    3. Importing Models
  3. Editing Models
    1. GAML Editor (Generalities)
    2. GAML Editor Tools
    3. Validation of Models
  4. Running Experiments
    1. Launching Experiments
    2. Experiments User interface
    3. Controls of experiments
    4. Parameters view
    5. Inspectors and monitors
    6. Displays
    7. Batch Specific UI
    8. Errors View
  5. Running Headless
    1. Getting Started
    2. Headless Legacy
    3. Headless Batch
  6. Preferences
  7. Troubleshooting
  1. Introduction
    1. Start with GAML
    2. Organization of a Model
    3. Basic programming concepts in GAML
  2. Manipulate basic Species
  3. Global Species
    1. Regular Species
    2. Defining Actions and Behaviors
    3. Interaction between Agents
    4. Attaching Skills
    5. Inheritance
  4. Defining Advanced Species
    1. Grid Species
    2. Graph Species
    3. Mirror Species
    4. Multi-Level Architecture
  5. Defining GUI Experiment
    1. Defining Parameters
    2. Defining Displays Generalities
    3. Defining 3D Displays
    4. Defining Charts
    5. Defining Monitors and Inspectors
    6. Defining Export files
    7. Defining User Interaction
  6. Classes and Objects
    1. Class Definition and Instantiation
    2. Attributes and Actions
    3. Inheritance
    4. Virtual Classes
    5. Advanced Features
  7. Exploring Models
    1. Run Several Simulations
    2. Batch Experiments
    3. Exploration Methods
  8. Optimizing Models
    1. Runtime Concepts
    2. Analyzing code performance
    3. Optimizing Models
  9. Multi-Paradigm Modeling
    1. Control Architecture
    2. Defining Differential Equations
  1. Manipulate OSM Data
  2. Cleaning OSM Data
  3. Diffusion
  4. Using Database
  5. Using Dataframes
  6. Using FIPA ACL
  7. Using BDI with BEN
  8. Using Driving Skill
  9. Manipulate dates
  10. Manipulate lights
  11. Using comodel
  12. Save and restore Simulations
  13. Using network
  14. Writing Unit Tests
  15. Ensure model's reproducibility
  16. Going further with extensions
    1. Calling R
    2. Using Graphical Editor
    3. Using Git from GAMA
  1. Built-in Species
  2. Built-in Skills
  3. Built-in Architecture
  4. Statements
  5. Data Type
  6. File Type
  7. Stats Extension
  8. Sound Extension
  9. BDI Extension
  10. FIPA Skill
  11. Expressions
    1. Literals
    2. Units and Constants
    3. Pseudo Variables
    4. Variables And Attributes
    5. Operators (Definition)
    6. Operators [A-A]
    7. Operators [B-C]
    8. Operators [D-H]
    9. Operators [I-M]
    10. Operators [N-R]
    11. Operators [S-Z]
  12. Exhaustive list of GAMA Keywords
  1. Installing the development version
    1. Install GAMA source code with Eclipse plugin
  2. Developing Extensions
    1. Developing Plugins
    2. Developing Skills
    3. Developing Statements
    4. Developing Operators
    5. Developing Types
    6. Developing Species
    7. Developing Control Architectures
    8. Index of annotations
  3. Introduction to GAMA Java API
    1. Architecture of GAMA
    2. IScope
  4. Using GAMA flags
  5. Creating a release of GAMA
  6. Documentation generation

  1. Predator Prey
  2. Road Traffic
  3. Incremental Model
  4. Luneray's flu
  5. BDI Agents
  6. Forager RL
  7. SIR Analysis
  8. 3D Model

  1. Team
  2. Projects using GAMA
  3. Scientific References
  4. Training Sessions

Resources

  1. Videos
  2. Conferences
  3. Pedagogical materials

Clone this wiki locally