Title: Statistics

1 Methods

In Ruby/GSL, all the GSL statistical functions are provided as methods for the GSL::Vector class, and singleton methods of the GSL::Stats module.

GSL::Stats.mean(v)
GSL::Vector#mean
Arithmetic mean
GSL::Stats.variance(v)
GSL::Vector#variance
Estimated variance
GSL::Stats.sd(v)
GSL::Vector#sd
Standard deviation

The following is a list of other methods defined both as singleton methods of the GSL::Stats module and methods of the GSL::Vector class. See the GSL reference for details.

These are singleton methods of the GSL::Stats module.

2 Example

#!/usr/bin/env ruby
require 'gsl'
include GSL

ary =  [17.2, 18.1, 16.5, 18.3, 12.6]
data = Vector.new(ary)
mean     = data.mean()
variance = data.stats_variance()
largest  = data.stats_max()
smallest = data.stats_min()

printf("The dataset is %g, %g, %g, %g, %g\n",
       data[0], data[1], data[2], data[3], data[4]);

printf("The sample mean is %g\n", mean);
printf("The estimated variance is %g\n", variance);
printf("The largest value is %g\n", largest);
printf("The smallest value is %g\n", smallest);

back