Did you know ... Search Documentation:
Pack logtalk -- logtalk-3.98.0/library/statistics/NOTES.md

This file is part of Logtalk https://logtalk.org/ SPDX-FileCopyrightText: 1998-2026 Paulo Moura <pmoura@logtalk.org> SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

statistics

The entities in this library define some useful predicates for descriptive statistics. Data is represented as a list of numbers (integers or floats). Use the object sample if your data represents a sample. Use the object population if your data represents a population.

The variance/2, standard_deviation/2, skewness/2, kurtosis/2, covariance/3, standard_error/2, correlation/3, and rank_correlation/3 predicates use different formulas depending on whether the data represents a sample (dividing by N-1) or a population (dividing by N). All other predicates share the same implementation.

API documentation

Open the [../../apis/library_index.html#statistics](../../apis/library_index.html#statistics) link in a web browser.

Loading

To load all entities in this library, load the loader.lgt file:

| ?- logtalk_load(statistics(loader)).

Testing

To test this library predicates, load the tester.lgt file:

| ?- logtalk_load(statistics(tester)).

API overview

Aggregation

PredicateDescription
product/2Product of all list numbers
sum/2Sum of all list numbers

Extremes and Range

PredicateDescription
min/2Minimum value
max/2Maximum value
min_max/3Minimum and maximum values
range/2Range (max - min)

Central Tendency

PredicateDescription
arithmetic_mean/2Arithmetic mean
geometric_mean/2Geometric mean
harmonic_mean/2Harmonic mean
weighted_mean/3Weighted mean
trimmed_mean/3Trimmed mean (removing a fraction of extreme values)
median/2Median
modes/2Modes (in ascending order)

Measures of Position / Quantiles

PredicateDescription
fractile/3Fractile (quantile given a fraction in (0.0, 1.0))
percentile/3Percentile (quantile given a value in (0, 100))
quartiles/4Quartiles (Q1, Q2, Q3)
interquartile_range/2Interquartile range (Q3 - Q1)

Measures of Dispersion

PredicateDescription
variance/2Variance (sample or population)
standard_deviation/2Standard deviation (sample or population)
mean_deviation/2Mean absolute deviation
median_deviation/2Median absolute deviation
average_deviation/3Average absolute deviation from a given central tendency
coefficient_of_variation/2Coefficient of variation
relative_standard_deviation/2Relative standard deviation (percentage)
sum_of_squares/2Sum of squared deviations from the mean
standard_error/2Standard error of the mean

Measures of Shape

PredicateDescription
skewness/2Moment skewness (sample or population)
kurtosis/2Excess kurtosis (sample or population)
central_moment/3K-th central moment

Measures of Association

PredicateDescription
covariance/3Covariance (sample or population)
correlation/3Pearson correlation coefficient
rank_correlation/3Spearman rank correlation coefficient

Error Metrics

PredicateDescription
mean_squared_error/3Mean squared error between two lists
root_mean_squared_error/3Root mean squared error between two lists

Normalization

PredicateDescription
z_normalization/2Z-score normalization (mean ~= 0, std ~= 1)
min_max_normalization/2Min-max normalization (rescale to [0, 1])

Frequency / Counting

PredicateDescription
frequency_distribution/2Frequency distribution (Value-Count pairs)

Validation

PredicateDescription
valid/1Term is a closed list of numbers