Math::GSL::RNG - Random Number Generators use Math::GSL::RNG; my $rng = Math::GSL::RNG->new; my @random = $rng->get(100);

Math::GSL::RNG->new($type, $seed)
my $rng = Math::GSL::RNG->new; my $rng = Math::GSL::RNG->new($gsl_rng_knuthran,5); Creates a new RNG object of type $type, seeded with $seed. Both of these parameters are optional. The type $gsl_rng_default is used when no $type is given.

copy()
my $copy = $rng->copy; Make a copy of a RNG object.

free()
$rng->free(); Free memory associated with RNG object.

name()
my $name = $rng->name(); Get the name of the RNG object as a string.

get()
my $nextval = $rng->get; my (@values) = $rng->get(100); Get the next random value from the RNG object. If given an integer N, returns the next N values.

raw()
my $raw = $rng->raw(); Return the raw GSL RNG object, useful for functions which take a RNG, such as the Monte Carlo integration functions or the random number distribution functions in Math::GSL::Randist. The original source code is available from NETLIB. For more information see, * W. Petersen, “Lagged Fibonacci Random Number Generators for the NEC SX-3”, International Journal of High Speed Computing (1994). For more informations on the functions, we refer you to the GSL offcial documentation: <http://www.gnu.org/software/gsl/manual/html_node/> Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want The following example will print out a list a random integers between certain minimum and maximum values. The command line arguments are first the number of random numbers wanted, the minimum and then maximum. The defaults are 10, 0 and 100, respectively. use Math::GSL::RNG qw/:all/; my $seed = int rand(100); my $rng = Math::GSL::RNG->new($gsl_rng_knuthran, $seed ); my ($num,$min,$max) = @ARGV; $num ||= 10; $min ||= 0; $max ||= 100; print join "\n", map { $min + $rng->get % ($max-$min+1) } (1..$num); print "\n"; The $seed argument is optional but encouraged. This program is available in the examples/ directory that comes with the source of this module. If you would like a series of random non-integer numbers, then you can generate one "scaling factor" and multiple by that, such as use Math::GSL::RNG qw/:all/; my $scale= rand(10); my $seed = int rand(100); my $rng = Math::GSL::RNG->new($gsl_rng_knuthran, $seed ); my ($num,$min,$max) = (10,0,100); print join "\n", map { $scale*($min + $rng->get % ($max-$min+1)) } (1..$num); print "\n"; Jonathan Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com> Copyright (C) 2008-2009 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.