Statistics

# 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.

- variance_m
- sd
- sd_m
- variace_with_fixed_mean
- sd_with_fixed_mean
- absdev
- absdev_m
- skew
- skew_m_sd
- kurtosis
- kurtosis_m_sd
- lag1_autocorrelation
- lag1_autocorrelation_m
- max
- min
- minmax
- max_index
- min_index
- minmax_index
- median_from_sorted_data
- uantile_from_sorted_data

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

- covariance
- covariance_m
- wmean
- wmean_m
- wvariance
- wvariance_m
- wsd
- wsd_m
- wvariance_with_fixed_mean
- wsd_with_fixed_mean
- wabsdev
- wabsdev_m
- wskew
- wskew_m_sd
- wkurtosis
- wkurtosis_m_sd

## 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