Extreme Optimization™: Complexity made simple.

Math and Statistics
Libraries for .NET

  • Home
  • Features
    • Math Library
    • Vector and Matrix Library
    • Statistics Library
    • Performance
    • Usability
  • Documentation
    • Introduction
    • Math Library User's Guide
    • Vector and Matrix Library User's Guide
    • Data Analysis Library User's Guide
    • Statistics Library User's Guide
    • Reference
  • Resources
    • Downloads
    • QuickStart Samples
    • Sample Applications
    • Frequently Asked Questions
    • Technical Support
  • Blog
  • Order
  • Company
    • About us
    • Testimonials
    • Customers
    • Press Releases
    • Careers
    • Partners
    • Contact us
Introduction
Deployment Guide
Nuget packages
Configuration
Using Parallelism
Expand Mathematics Library User's GuideMathematics Library User's Guide
Expand Vector and Matrix Library User's GuideVector and Matrix Library User's Guide
Expand Data Analysis Library User's GuideData Analysis Library User's Guide
Expand Statistics Library User's GuideStatistics Library User's Guide
Expand Data Access Library User's GuideData Access Library User's Guide
Expand ReferenceReference
  • Extreme Optimization
    • Features
    • Solutions
    • Documentation
    • QuickStart Samples
    • Sample Applications
    • Downloads
    • Technical Support
    • Download trial
    • How to buy
    • Blog
    • Company
    • Resources
  • Documentation
    • Introduction
    • Deployment Guide
    • Nuget packages
    • Configuration
    • Using Parallelism
    • Mathematics Library User's Guide
    • Vector and Matrix Library User's Guide
    • Data Analysis Library User's Guide
    • Statistics Library User's Guide
    • Data Access Library User's Guide
    • Reference
  • Data Analysis Library User's Guide
    • Indexes
    • Data Frames
    • Data wrangling
    • Grouping and Aggregation
    • Working with Categorical Data
    • Working with Time Series Data
  • Grouping and Aggregation
    • Groupings
    • Aggregators
    • Aggregating data frames
    • Aggregating vectors and matrices
  • Aggregators

Aggregators

Extreme Optimization Numerical Libraries for .NET Professional

Aggregation is the process of reducing a collection of values to a single value that represents some property of the collection. An aggregate function or aggregator is a function that performs this operation. This section describes predefined aggregators and a simple mechanism to create your own. Examples of aggregators are: count, largest value, mean...

Aggregator groups and aggregators

A property like the number of elements or the number of elements that are not missing in a collection is meaningful for all collections regardless of their element type. The result is always an integer. A property like the first element is also universally relevant, but the type of the result depends on the element type. More than that, the type of the result is equal to the element type. These two examples illustrate the two main kinds of aggregators: those where the result is of a specific type, and those where the result type is the same as the element type.

The most common aggregators are defined as static properties or methods of the Aggregators class, and are listed below.

Member

Description

Count

Computes the number of non-missing values.

Max

Returns the largest value.

Min

Returns the smallest value.

First

Returns the first non-missing value.

Last

Returns the last non-missing value.

Skip(Int32)

Returns the first non-missing value after skipping the specified number of non-missing values.

Mean

Returns the mean of the non-missing values.

Sum

Returns the sum of the non-missing values.

Variance

Returns the sample variance of the non-missing values.

StandardDeviation

Returns the sample standard deviation of the non-missing values.

Skewness

Returns the skewness of the non-missing values.

Kurtosis

Returns the kurtosis of the non-missing values.

Median

Returns the median of the non-missing values.

FirstQuartile

Returns the 25% quantile of the non-missing values.

ThirdQuartile

Returns the 75% quantile of the non-missing values.

Quantile(Double)

Returns the quantile at the specified probability of the non-missing values.

ExactSum

Returns the sum of the non-missing values preserving the element type.

The above properties and methods return an aggregator group. An aggregator group represents an aggregation operation in a way that is independent of the element type. When the aggregator group is applied to a collection, an aggregator function for the element type of the collection is selected to perform the actual operation. AggregatorGroup is an abstract class that represents an aggregator group. It has two descendant classes corresponding to the two kinds of aggregators mentioned above: AggregatorGroupT represents an aggregator group where the generic type argument is the return type, and TypePreservingAggregatorGroup represents an aggregator group where the return type is the same as the element type.

Aggregators that compute numerical descriptive statistics, like Mean and Variance always return a Double value regardless of the element type. To preserve the element type in the result, use the 'exact' variant, like ExactSum.

Aggregating over multiple collections

Some aggregations, such as the correlation between two variables, involve more than one collection. The Aggregators class defines a number of aggregators that operate on more than one collection:

Member

Description

Correlation

Computes the correlation between two sets of values.

Covariance

Computes the covariance between two sets of values.

WeightedMean

Computes the mean of one set of values weighted by another.

WeightedStandardDeviation

Computes the standard deviation of one set of values weighted by another.

WeightedVariance

Computes the variance of one set of values weighted by another.

User-defined aggregators

The simplest way to define an aggregator that is not available from the Aggregators class is to use the AggregatorsCreate method. This method takes two arguments: a name for the aggregator, and a delegate that maps a vector to the aggregated value. The following creates an aggregator that computes the geometric mean:

C#
VB
C++
F#
Copy
var agg = Aggregators.Create("geo.mean", 
    (Vector<double> x) => Stats.GeometricMean(x));
Dim agg = Aggregators.Create("geo.mean",
    Function(x As Vector(Of Double)) Stats.GeometricMean(x))

No code example is currently available or this language may not be supported.

let agg = Aggregators.Create("geo.mean", 
            fun (x : Vector<float>) -> Stats.GeometricMean(x))

Copyright (c) 2004-2021 ExoAnalytics Inc.

Send comments on this topic to support@extremeoptimization.com

Copyright © 2004-2021, Extreme Optimization. All rights reserved.
Extreme Optimization, Complexity made simple, M#, and M Sharp are trademarks of ExoAnalytics Inc.
Microsoft, Visual C#, Visual Basic, Visual Studio, Visual Studio.NET, and the Optimized for Visual Studio logo
are registered trademarks of Microsoft Corporation.