NMath Stats User's Guide

TOC | Previous | Next | Index

Chapter 3. Descriptive Statistics (.NET, C#, CSharp, VB, Visual Basic, F#)

Class StatsFunctions provides a wide variety of static functions for computing descriptive statistics, such as mean, variance, standard deviation, percentile, median, quartiles, geometric mean, harmonic mean, RMS, kurtosis, skewness, and many more.

Method overloads accept data as an array of doubles, as a DoubleVector, or as a column in a DataFrame (Chapter 2). For example:

Code Example – C#

double[] dblArray = { 1.12, -2.0, 3.88, 1.2, 15.345 };
double mean1 = StatsFunctions.Mean( dblArray );

var v = new DoubleVector( "1.12 -2.0 3.88 1.2 15.345"  );
double mean2 = StatsFunctions.Mean( v );

var df = new DataFrame();
df.AddColumn(
  new DFNumericColumn( "myData", 1.12, -2.0, 3.88, 1.2, 15.345 ) );
double mean3 = StatsFunctions.Mean( df[ "myData" ] );  

// mean1 == mean2 == mean3

In this chapter, where data is used in code examples, it should be understood to be an instance of any of these three types.


Top

Top