Math::GSL::Histogram - Create and manipulate histograms of data
use Math::GSL::Histogram qw/:all/; my $H = gsl_histogram_alloc(100); gsl_histogram_set_ranges_uniform($H,0,101); gsl_histogram_increment($H, -50 ); # ignored gsl_histogram_increment($H, 70 ); gsl_histogram_increment($H, 85.2 ); my $G = gsl_histogram_clone($H); my $value = gsl_histogram_get($G, 70); my ($max,$min) = (gsl_histogram_min_val($H), gsl_histogram_max_val($H) ); my $sum = gsl_histogram_sum($H);
Here is a list of all the functions included in this module :
gsl_histogram_alloc($n)
gsl_histogram_calloc
gsl_histogram_calloc_uniform
gsl_histogram_free($h)
gsl_histogram_increment($h, $x)
gsl_histogram_accumulate($h, $x, $weight)
gsl_histogram_find($h, $x)
gsl_histogram_get($h, $i)
gsl_histogram_get_range($h, $i)
gsl_histogram_max($h)
gsl_histogram_min($h)
gsl_histogram_bins($h)
gsl_histogram_reset($h)
gsl_histogram_calloc_range
gsl_histogram_set_ranges($h, $range, $size)
gsl_histogram_set_ranges_uniform($h, $xmin, $xmax)
where d is the bin spacing, d = (xmax-xmin)/n.
gsl_histogram_memcpy($dest, $src)
gsl_histogram_clone($src)
gsl_histogram_max_val($h)
gsl_histogram_max_bin($h)
gsl_histogram_min_val($h)
gsl_histogram_min_bin($h)
gsl_histogram_equal_bins_p($h1, $h2)
gsl_histogram_add($h1, $h2)
gsl_histogram_sub($h1, $h2)
gsl_histogram_mul($h1, $h2)
gsl_histogram_div($h1, $h2)
gsl_histogram_scale($h, $scale)
gsl_histogram_shift($h, $offset)
gsl_histogram_sigma($h)
gsl_histogram_mean($h)
gsl_histogram_sum($h)
gsl_histogram_fwrite($stream, $h)
gsl_histogram_fread($stream, $h)
gsl_histogram_fprintf($stream, $h, $range_format, $bin_format)
The values of the ranges are formatted using range_format and the value of the bins are formatted using bin_format. Each line contains the lower and upper limit of the range of the bins and the value of the bin itself. Since the upper limit of one bin is the lower limit of the next there is duplication of these values between lines but this allows the histogram to be manipulated with line-oriented tools.
gsl_histogram_fscanf($stream, $h)
gsl_histogram_pdf_alloc($n)
gsl_histogram_pdf_init($p, $h)
gsl_histogram_pdf_free($p)
gsl_histogram_pdf_sample($p, $r)
The following example shows how to create a histogram with logarithmic bins with ranges [1,10), [10,100) and [100,1000). $h = gsl_histogram_alloc (3); # bin[0] covers the range 1 <= x < 10 # bin[1] covers the range 10 <= x < 100 # bin[2] covers the range 100 <= x < 1000 $range = [ 1.0, 10.0, 100.0, 1000.0 ]; gsl_histogram_set_ranges($h, $range, 4);
Jonathan Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com>
Copyright (C) 2008 Jonathan Leto and Thierry Moisan
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Math::GSL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::GSL
CPAN shell
perl -MCPAN -e shell install Math::GSL
For more information on module installation, please visit the detailed CPAN module installation guide.