GSL: The GNU Scientific Library

GSL is a library that provides many useful scientific functions, including random number generation, random number distributions, statistics, fast fourier transform, and root finding. The latest version is gsl-0.4.1 released January 1999. The source code is installed in /usr/dirt/src/gsl-0.4.1/, the library files (compiled on FreeBSD 2.2.8) are in /usr/dirt/lib/, and the header files are in /usr/dirt/include/.

On this web page, I've included links to the GSL main web page and the GSL manual, a list of available random number distributions, an example on how to use GSL in your own program, and some notes on how to re-build the library.

Sources of Information

Available Distributions

gaussian (sigma) bivariate gaussian (sigma_x, sigma_y, rho, x, y) exponential (mu)
laplace (mu) exponential power (mu, a) cauchy (mu)
rayleigh (sigma) rayleigh tail (a, sigma) symmetric levy (mu, a)
gamma (a, b) flat/uniform (a, b) lognormal (zeta, sigma)
chi-squared (mu) F-distribution (nu1, nu2) t-distribution (nu)
beta (a, b) logistic (mu) pareto (a, b)
spherical_2d (x, y) spherical_3d (x, y, z) weibull (mu, a) gumbel (a, b)


poisson (mu) bernoulli (p) binomial (p, n)
negative binomial (p, n) geometric (p) hypergeometric (n1, n2, t) logarithmic (p)

Example (Random Number Distribution)

#include "gsl_randist.h"

int main (void) 
  double packet_size;
  long seed;
  gsl_rng *rng;  // random number generator

  rng = gsl_rng_alloc (gsl_rng_rand48);     // pick random number generator
  seed = time (NULL) * getpid();    
  gsl_rng_set (rng, seed);                  // set seed
  packet_size = gsl_ran_exponential (1500); // get a random number from
                                            // the exponential distribution
  gsl_rng_free (rng);                       // dealloc the rng   

% gcc -L /usr/dirt/lib -lgslrandist -lgslrng -lgslerr -lgslspecfunc [..]
Note -- If you want to use GSL with C++, include the gsl header file like this:
extern "C" {
  #include "gsl_randist.h"

Notes on Re-building GSL

Other DiRT documents
Author: Michele Clark