NAME

PDL::GSL::RNG - PDL interface to RNG and randist routines in GSL

DESCRIPTION

This is an interface to the rng and randist packages present in the GNU Scientific Library.

SYNOPSIS

use PDL;
use PDL::GSL::RNG;

$rng = PDL::GSL::RNG->new('taus');

$rng->set_seed(time());

$x=zeroes(5,5,5)

$rng->get_uniform($x); # inplace

$y=$rng->get_uniform(3,4,5); # creates new pdl

NOMENCLATURE

Throughout this documentation we strive to use the same variables that are present in the original GSL documentation (see See Also). Oftentimes those variables are called a and b. Since good Perl coding practices discourage the use of Perl variables $a and $b, here we refer to Parameters a and b as $pa and $pb, respectively, and Limits (of domain or integration) as $la and $lb.

FUNCTIONS

new

The new method initializes a new instance of the RNG.

The available RNGs are:

coveyou
cmrg
fishman18
fishman20
fishman2x
gfsr4
knuthran
knuthran2
knuthran2002
lecuyer21
minstd
mrg
mt19937
mt19937_1999
mt19937_1998
r250
ran0
ran1
ran2
ran3
rand
rand48
random128_bsd
random128_glibc2
random128_libc5
random256_bsd
random256_glibc2
random256_libc5
random32_bsd
random32_glibc2
random32_libc5
random64_bsd
random64_glibc2
random64_libc5
random8_bsd
random8_glibc2
random8_libc5
random_bsd
random_glibc2
random_libc5
randu
ranf
ranlux
ranlux389
ranlxd1
ranlxd2
ranlxs0
ranlxs1
ranlxs2
ranmar
slatec
taus
taus2
taus113
transputer
tt800
uni
uni32
vax
waterman14
zuf
default

The last one (default) uses the environment variable GSL_RNG_TYPE.

Note that only a few of these rngs are recommended for general use. Please check the GSL documentation for more information.

Usage:

$blessed_ref = PDL::GSL::RNG->new($RNG_name);

Example:

$rng = PDL::GSL::RNG->new('taus');

set_seed

Sets the RNG seed.

Usage:

$rng->set_seed($integer);
# or
$rng = PDL::GSL::RNG->new('taus')->set_seed($integer);

Example:

$rng->set_seed(666);

min

Return the minimum value generable by this RNG.

Usage:

$integer = $rng->min();

Example:

$min = $rng->min(); $max = $rng->max();

max

Return the maximum value generable by the RNG.

Usage:

$integer = $rng->max();

Example:

$min = $rng->min(); $max = $rng->max();

name

Returns the name of the RNG.

Usage:

$string = $rng->name();

Example:

$name = $rng->name();

ran_shuffle

Shuffles values in ndarray, treating it as flat.

Usage:

$rng->ran_shuffle($ndarray);

ran_shuffle_vec

Returns values in Perl list, shuffled.

Usage:

@shuffled = $rng->ran_shuffle_vec(@vec);

ran_choose

Chooses values from $inndarray to $outndarray, treating both as flat.

Usage:

$rng->ran_choose($inndarray,$outndarray);

ran_choose_vec

Chooses $n values from @vec.

Usage:

@chosen = $rng->ran_choose_vec($n,@vec);

ran_dir

Returns $n random vectors in $ndim dimensions.

Usage:

$ndarray = $rng->ran_dir($ndim,$n);

Example:

$o = $rng->ran_dir($ndim,$n);

ran_discrete_preproc

This method returns a handle that must be used when calling "ran_discrete". You specify the probability of the integer number that are returned by "ran_discrete".

Usage:

$discrete_dist_handle = $rng->ran_discrete_preproc($double_ndarray_prob);

Example:

$prob = pdl [0.1,0.3,0.6];
$ddh = $rng->ran_discrete_preproc($prob);
$o = $rng->ran_discrete($discrete_dist_handle,100);

ran_bernoulli_pdf

Signature: (uint k(); p(); [o]out())

ran_bernoulli_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_beta_pdf

Signature: (x(); a(); b(); [o]out())

ran_beta_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_binomial_pdf

Signature: (uint k(); p(); uint n(); [o]out())

ran_binomial_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_bivariate_gaussian_pdf

Signature: (x(); y(); sigma_x(); sigma_y(); rho(); [o]out())

ran_bivariate_gaussian_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_cauchy_pdf

Signature: (x(); a(); [o]out())

ran_cauchy_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_chisq_pdf

Signature: (x(); nu(); [o]out())

ran_chisq_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_dirichlet_pdf

Signature: (alpha(k); theta(k); [o]out())

ran_dirichlet_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_erlang_pdf

Signature: (x(); a(); n(); [o]out())

ran_erlang_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_exponential_pdf

Signature: (x(); mu(); [o]out())

ran_exponential_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_exppow_pdf

Signature: (x(); a(); b(); [o]out())

ran_exppow_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_fdist_pdf

Signature: (x(); nua(); nub(); [o]out())

ran_fdist_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_flat_pdf

Signature: (x(); a(); b(); [o]out())

ran_flat_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_gamma_pdf

Signature: (x(); a(); b(); [o]out())

ran_gamma_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_gaussian_pdf

Signature: (x(); sigma(); [o]out())

ran_gaussian_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_gaussian_tail_pdf

Signature: (x(); a(); sigma(); [o]out())

ran_gaussian_tail_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_geometric_pdf

Signature: (uint k(); p(); [o]out())

ran_geometric_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_gumbel1_pdf

Signature: (x(); a(); b(); [o]out())

ran_gumbel1_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_gumbel2_pdf

Signature: (x(); a(); b(); [o]out())

ran_gumbel2_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_hypergeometric_pdf

Signature: (uint k(); uint na(); uint nb(); uint t(); [o]out())

ran_hypergeometric_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_landau_pdf

Signature: (x(); [o]out())

ran_landau_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_laplace_pdf

Signature: (x(); a(); [o]out())

ran_laplace_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_logarithmic_pdf

Signature: (uint k(); p(); [o]out())

ran_logarithmic_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_logistic_pdf

Signature: (x(); a(); [o]out())

ran_logistic_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_lognormal_pdf

Signature: (x(); zeta(); sigma(); [o]out())

ran_lognormal_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_multinomial_pdf

Signature: (p(k); uint n(k); [o]out())

ran_multinomial_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_negative_binomial_pdf

Signature: (uint k(); p(); n(); [o]out())

ran_negative_binomial_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_pareto_pdf

Signature: (x(); a(); b(); [o]out())

ran_pareto_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_pascal_pdf

Signature: (uint k(); p(); uint n(); [o]out())

ran_pascal_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_poisson_pdf

Signature: (uint k(); mu(); [o]out())

ran_poisson_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_rayleigh_pdf

Signature: (x(); sigma(); [o]out())

ran_rayleigh_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_rayleigh_tail_pdf

Signature: (x(); a(); sigma(); [o]out())

ran_rayleigh_tail_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_tdist_pdf

Signature: (x(); nu(); [o]out())

ran_tdist_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_ugaussian_pdf

Signature: (x(); [o]out())

ran_ugaussian_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_ugaussian_tail_pdf

Signature: (x(); a(); [o]out())

ran_ugaussian_tail_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_weibull_pdf

Signature: (x(); a(); b(); [o]out())

ran_weibull_pdf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_shuffle_1d

Signature: ([io]a(n); gsl_rng *rng)

Takes n-dimensional ndarray, and shuffles it along its zero-th dimension.

Usage:

$vec2d = sequence(10,10);
$rng->ran_shuffle_1d($vec2d);

ran_shuffle_1d does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

get_uniform

Signature: ([o]a(); gsl_rng *rng)

This function creates an ndarray with given dimensions or accepts an existing ndarray and fills it. get_uniform() returns values 0<=x<1,

Usage:

$ndarray = $rng->get_uniform($list_of_integers)
$rng->get_uniform($ndarray);

Example:

$x = zeroes 5,6; $max=100;
$o = $rng->get_uniform(10,10); $rng->get_uniform($x);

get_uniform does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

get_uniform_pos

Signature: ([o]a(); gsl_rng *rng)

This function creates an ndarray with given dimensions or accepts an existing ndarray and fills it. get_uniform_pos() returns values 0<x<1,

Usage:

$ndarray = $rng->get_uniform_pos($list_of_integers)
$rng->get_uniform_pos($ndarray);

Example:

$x = zeroes 5,6;
$o = $rng->get_uniform_pos(10,10); $rng->get_uniform_pos($x);

get_uniform_pos does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

get

Signature: ([o]a(); gsl_rng *rng)

This function creates an ndarray with given dimensions or accepts an existing ndarray and fills it. get() returns integer values between a minimum and a maximum specific to every RNG.

Usage:

$ndarray = $rng->get($list_of_integers)
$rng->get($ndarray);

Example:

$x = zeroes 5,6;
$o = $rng->get(10,10); $rng->get($x);

get does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

get_int

Signature: ([o]a(); IV n; gsl_rng *rng)

This function creates an ndarray with given dimensions or accepts an existing ndarray and fills it. get_int() returns integer values between 0 and $max.

Usage:

$ndarray = $rng->get($max, $list_of_integers)
$rng->get($max, $ndarray);

Example:

$x = zeroes 5,6; $max=100;
$o = $rng->get(10,10); $rng->get($x);

get_int does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_gaussian

Signature: ([o]output(); double sigma; gsl_rng *rng)

Fills output ndarray with random values from Gaussian distribution with mean zero and standard deviation $sigma.

Usage:

$ndarray = $rng->ran_gaussian($sigma,[list of integers = output ndarray dims]);
$rng->ran_gaussian($sigma, $output_ndarray);

Example:

$o = $rng->ran_gaussian($sigma,10,10);
$rng->ran_gaussian($sigma,$o);

ran_gaussian does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_gaussian_var

Signature: (sigma();[o]output(); gsl_rng *rng)

Similar to "ran_gaussian" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_gaussian_var($sigma_ndarray);

ran_gaussian_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_ugaussian_tail

Signature: ([o]output(); double tail; gsl_rng *rng)

Fills output ndarray with random variates from the upper tail of a Gaussian distribution with standard deviation = 1 (AKA unit Gaussian distribution).

Usage:

$ndarray = $rng->ran_ugaussian_tail($tail,[list of integers = output ndarray dims]);
$rng->ran_ugaussian_tail($tail, $output_ndarray);

Example:

$o = $rng->ran_ugaussian_tail($tail,10,10);
$rng->ran_ugaussian_tail($tail,$o);

ran_ugaussian_tail does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_ugaussian_tail_var

Signature: (tail();[o]output(); gsl_rng *rng)

Similar to "ran_ugaussian_tail" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_ugaussian_tail_var($tail_ndarray);

ran_ugaussian_tail_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_exponential

Signature: ([o]output(); double mu; gsl_rng *rng)

Fills output ndarray with random variates from the exponential distribution with mean $mu.

Usage:

$ndarray = $rng->ran_exponential($mu,[list of integers = output ndarray dims]);
$rng->ran_exponential($mu, $output_ndarray);

Example:

$o = $rng->ran_exponential($mu,10,10);
$rng->ran_exponential($mu,$o);

ran_exponential does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_exponential_var

Signature: (mu();[o]output(); gsl_rng *rng)

Similar to "ran_exponential" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_exponential_var($mu_ndarray);

ran_exponential_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_laplace

Signature: ([o]output(); double pa; gsl_rng *rng)

Fills output ndarray with random variates from the Laplace distribution with width $pa.

Usage:

$ndarray = $rng->ran_laplace($pa,[list of integers = output ndarray dims]);
$rng->ran_laplace($pa, $output_ndarray);

Example:

$o = $rng->ran_laplace($pa,10,10);
$rng->ran_laplace($pa,$o);

ran_laplace does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_laplace_var

Signature: (pa();[o]output(); gsl_rng *rng)

Similar to "ran_laplace" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_laplace_var($pa_ndarray);

ran_laplace_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_exppow

Signature: ([o]output(); double pa; double pb; gsl_rng *rng)

Fills output ndarray with random variates from the exponential power distribution with scale parameter $pa and exponent $pb.

Usage:

$ndarray = $rng->ran_exppow($pa, $pb,[list of integers = output ndarray dims]);
$rng->ran_exppow($pa, $pb, $output_ndarray);

Example:

$o = $rng->ran_exppow($pa, $pb,10,10);
$rng->ran_exppow($pa, $pb,$o);

ran_exppow does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_exppow_var

Signature: (pa();pb();[o]output(); gsl_rng *rng)

Similar to "ran_exppow" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_exppow_var($pa_ndarray,$pb_ndarray);

ran_exppow_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_cauchy

Signature: ([o]output(); double pa; gsl_rng *rng)

Fills output ndarray with random variates from the Cauchy distribution with scale parameter $pa.

Usage:

$ndarray = $rng->ran_cauchy($pa,[list of integers = output ndarray dims]);
$rng->ran_cauchy($pa, $output_ndarray);

Example:

$o = $rng->ran_cauchy($pa,10,10);
$rng->ran_cauchy($pa,$o);

ran_cauchy does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_cauchy_var

Signature: (pa();[o]output(); gsl_rng *rng)

Similar to "ran_cauchy" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_cauchy_var($pa_ndarray);

ran_cauchy_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_rayleigh

Signature: ([o]output(); double sigma; gsl_rng *rng)

Fills output ndarray with random variates from the Rayleigh distribution with scale parameter $sigma.

Usage:

$ndarray = $rng->ran_rayleigh($sigma,[list of integers = output ndarray dims]);
$rng->ran_rayleigh($sigma, $output_ndarray);

Example:

$o = $rng->ran_rayleigh($sigma,10,10);
$rng->ran_rayleigh($sigma,$o);

ran_rayleigh does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_rayleigh_var

Signature: (sigma();[o]output(); gsl_rng *rng)

Similar to "ran_rayleigh" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_rayleigh_var($sigma_ndarray);

ran_rayleigh_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_rayleigh_tail

Signature: ([o]output(); double x; double sigma; gsl_rng *rng)

Fills output ndarray with random variates from the tail of the Rayleigh distribution with scale parameter $sigma and a lower limit of $la.

Usage:

$ndarray = $rng->ran_rayleigh_tail($x, $sigma,[list of integers = output ndarray dims]);
$rng->ran_rayleigh_tail($x, $sigma, $output_ndarray);

Example:

$o = $rng->ran_rayleigh_tail($x, $sigma,10,10);
$rng->ran_rayleigh_tail($x, $sigma,$o);

ran_rayleigh_tail does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_rayleigh_tail_var

Signature: (x();sigma();[o]output(); gsl_rng *rng)

Similar to "ran_rayleigh_tail" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_rayleigh_tail_var($x_ndarray,$sigma_ndarray);

ran_rayleigh_tail_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_levy

Signature: ([o]output(); double mu; double x; gsl_rng *rng)

Fills output ndarray with random variates from the Levy symmetric stable distribution with scale $c and exponent $alpha.

Usage:

$ndarray = $rng->ran_levy($mu, $x,[list of integers = output ndarray dims]);
$rng->ran_levy($mu, $x, $output_ndarray);

Example:

$o = $rng->ran_levy($mu, $x,10,10);
$rng->ran_levy($mu, $x,$o);

ran_levy does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_levy_var

Signature: (mu();x();[o]output(); gsl_rng *rng)

Similar to "ran_levy" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_levy_var($mu_ndarray,$x_ndarray);

ran_levy_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_gamma

Signature: ([o]output(); double pa; double pb; gsl_rng *rng)

Fills output ndarray with random variates from the gamma distribution.

Usage:

$ndarray = $rng->ran_gamma($pa, $pb,[list of integers = output ndarray dims]);
$rng->ran_gamma($pa, $pb, $output_ndarray);

Example:

$o = $rng->ran_gamma($pa, $pb,10,10);
$rng->ran_gamma($pa, $pb,$o);

ran_gamma does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_gamma_var

Signature: (pa();pb();[o]output(); gsl_rng *rng)

Similar to "ran_gamma" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_gamma_var($pa_ndarray,$pb_ndarray);

ran_gamma_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_flat

Signature: ([o]output(); double la; double lb; gsl_rng *rng)

Fills output ndarray with random variates from the flat (uniform) distribution from $la to $lb.

Usage:

$ndarray = $rng->ran_flat($la, $lb,[list of integers = output ndarray dims]);
$rng->ran_flat($la, $lb, $output_ndarray);

Example:

$o = $rng->ran_flat($la, $lb,10,10);
$rng->ran_flat($la, $lb,$o);

ran_flat does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_flat_var

Signature: (la();lb();[o]output(); gsl_rng *rng)

Similar to "ran_flat" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_flat_var($la_ndarray,$lb_ndarray);

ran_flat_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_lognormal

Signature: ([o]output(); double mu; double sigma; gsl_rng *rng)

Fills output ndarray with random variates from the lognormal distribution with parameters $mu (location) and $sigma (scale).

Usage:

$ndarray = $rng->ran_lognormal($mu, $sigma,[list of integers = output ndarray dims]);
$rng->ran_lognormal($mu, $sigma, $output_ndarray);

Example:

$o = $rng->ran_lognormal($mu, $sigma,10,10);
$rng->ran_lognormal($mu, $sigma,$o);

ran_lognormal does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_lognormal_var

Signature: (mu();sigma();[o]output(); gsl_rng *rng)

Similar to "ran_lognormal" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_lognormal_var($mu_ndarray,$sigma_ndarray);

ran_lognormal_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_chisq

Signature: ([o]output(); double nu; gsl_rng *rng)

Fills output ndarray with random variates from the chi-squared distribution with $nu degrees of freedom.

Usage:

$ndarray = $rng->ran_chisq($nu,[list of integers = output ndarray dims]);
$rng->ran_chisq($nu, $output_ndarray);

Example:

$o = $rng->ran_chisq($nu,10,10);
$rng->ran_chisq($nu,$o);

ran_chisq does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_chisq_var

Signature: (nu();[o]output(); gsl_rng *rng)

Similar to "ran_chisq" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_chisq_var($nu_ndarray);

ran_chisq_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_fdist

Signature: ([o]output(); double nu1; double nu2; gsl_rng *rng)

Fills output ndarray with random variates from the F-distribution with degrees of freedom $nu1 and $nu2.

Usage:

$ndarray = $rng->ran_fdist($nu1, $nu2,[list of integers = output ndarray dims]);
$rng->ran_fdist($nu1, $nu2, $output_ndarray);

Example:

$o = $rng->ran_fdist($nu1, $nu2,10,10);
$rng->ran_fdist($nu1, $nu2,$o);

ran_fdist does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_fdist_var

Signature: (nu1();nu2();[o]output(); gsl_rng *rng)

Similar to "ran_fdist" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_fdist_var($nu1_ndarray,$nu2_ndarray);

ran_fdist_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_tdist

Signature: ([o]output(); double nu; gsl_rng *rng)

Fills output ndarray with random variates from the t-distribution (AKA Student's t-distribution) with $nu degrees of freedom.

Usage:

$ndarray = $rng->ran_tdist($nu,[list of integers = output ndarray dims]);
$rng->ran_tdist($nu, $output_ndarray);

Example:

$o = $rng->ran_tdist($nu,10,10);
$rng->ran_tdist($nu,$o);

ran_tdist does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_tdist_var

Signature: (nu();[o]output(); gsl_rng *rng)

Similar to "ran_tdist" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_tdist_var($nu_ndarray);

ran_tdist_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_beta

Signature: ([o]output(); double pa; double pb; gsl_rng *rng)

Fills output ndarray with random variates from the beta distribution with parameters $pa and $pb.

Usage:

$ndarray = $rng->ran_beta($pa, $pb,[list of integers = output ndarray dims]);
$rng->ran_beta($pa, $pb, $output_ndarray);

Example:

$o = $rng->ran_beta($pa, $pb,10,10);
$rng->ran_beta($pa, $pb,$o);

ran_beta does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_beta_var

Signature: (pa();pb();[o]output(); gsl_rng *rng)

Similar to "ran_beta" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_beta_var($pa_ndarray,$pb_ndarray);

ran_beta_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_logistic

Signature: ([o]output(); double m; gsl_rng *rng)

Fills output ndarray with random random variates from the logistic distribution.

Usage:

$ndarray = $rng->ran_logistic($m,[list of integers = output ndarray dims]);
$rng->ran_logistic($m, $output_ndarray);

Example:

$o = $rng->ran_logistic($m,10,10);
$rng->ran_logistic($m,$o);

ran_logistic does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_logistic_var

Signature: (m();[o]output(); gsl_rng *rng)

Similar to "ran_logistic" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_logistic_var($m_ndarray);

ran_logistic_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_pareto

Signature: ([o]output(); double pa; double lb; gsl_rng *rng)

Fills output ndarray with random variates from the Pareto distribution of order $pa and scale $lb.

Usage:

$ndarray = $rng->ran_pareto($pa, $lb,[list of integers = output ndarray dims]);
$rng->ran_pareto($pa, $lb, $output_ndarray);

Example:

$o = $rng->ran_pareto($pa, $lb,10,10);
$rng->ran_pareto($pa, $lb,$o);

ran_pareto does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_pareto_var

Signature: (pa();lb();[o]output(); gsl_rng *rng)

Similar to "ran_pareto" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_pareto_var($pa_ndarray,$lb_ndarray);

ran_pareto_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_weibull

Signature: ([o]output(); double pa; double pb; gsl_rng *rng)

Fills output ndarray with random variates from the Weibull distribution with scale $pa and exponent $pb. (Some literature uses lambda for $pa and k for $pb.)

Usage:

$ndarray = $rng->ran_weibull($pa, $pb,[list of integers = output ndarray dims]);
$rng->ran_weibull($pa, $pb, $output_ndarray);

Example:

$o = $rng->ran_weibull($pa, $pb,10,10);
$rng->ran_weibull($pa, $pb,$o);

ran_weibull does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_weibull_var

Signature: (pa();pb();[o]output(); gsl_rng *rng)

Similar to "ran_weibull" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_weibull_var($pa_ndarray,$pb_ndarray);

ran_weibull_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_gumbel1

Signature: ([o]output(); double pa; double pb; gsl_rng *rng)

Fills output ndarray with random variates from the Type-1 Gumbel distribution.

Usage:

$ndarray = $rng->ran_gumbel1($pa, $pb,[list of integers = output ndarray dims]);
$rng->ran_gumbel1($pa, $pb, $output_ndarray);

Example:

$o = $rng->ran_gumbel1($pa, $pb,10,10);
$rng->ran_gumbel1($pa, $pb,$o);

ran_gumbel1 does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_gumbel1_var

Signature: (pa();pb();[o]output(); gsl_rng *rng)

Similar to "ran_gumbel1" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_gumbel1_var($pa_ndarray,$pb_ndarray);

ran_gumbel1_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_gumbel2

Signature: ([o]output(); double pa; double pb; gsl_rng *rng)

Fills output ndarray with random variates from the Type-2 Gumbel distribution.

Usage:

$ndarray = $rng->ran_gumbel2($pa, $pb,[list of integers = output ndarray dims]);
$rng->ran_gumbel2($pa, $pb, $output_ndarray);

Example:

$o = $rng->ran_gumbel2($pa, $pb,10,10);
$rng->ran_gumbel2($pa, $pb,$o);

ran_gumbel2 does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_gumbel2_var

Signature: (pa();pb();[o]output(); gsl_rng *rng)

Similar to "ran_gumbel2" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_gumbel2_var($pa_ndarray,$pb_ndarray);

ran_gumbel2_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_poisson

Signature: ([o]output(); double mu; gsl_rng *rng)

Fills output ndarray with random integer values from the Poisson distribution with mean $mu.

Usage:

$ndarray = $rng->ran_poisson($mu,[list of integers = output ndarray dims]);
$rng->ran_poisson($mu, $output_ndarray);

Example:

$o = $rng->ran_poisson($mu,10,10);
$rng->ran_poisson($mu,$o);

ran_poisson does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_poisson_var

Signature: (mu();[o]output(); gsl_rng *rng)

Similar to "ran_poisson" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_poisson_var($mu_ndarray);

ran_poisson_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_bernoulli

Signature: ([o]output(); double p; gsl_rng *rng)

Fills output ndarray with random values 0 or 1, the result of a Bernoulli trial with probability $p.

Usage:

$ndarray = $rng->ran_bernoulli($p,[list of integers = output ndarray dims]);
$rng->ran_bernoulli($p, $output_ndarray);

Example:

$o = $rng->ran_bernoulli($p,10,10);
$rng->ran_bernoulli($p,$o);

ran_bernoulli does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_bernoulli_var

Signature: (p();[o]output(); gsl_rng *rng)

Similar to "ran_bernoulli" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_bernoulli_var($p_ndarray);

ran_bernoulli_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_binomial

Signature: ([o]output(); double p; double n; gsl_rng *rng)

Fills output ndarray with random integer values from the binomial distribution, the number of successes in $n independent trials with probability $p.

Usage:

$ndarray = $rng->ran_binomial($p, $n,[list of integers = output ndarray dims]);
$rng->ran_binomial($p, $n, $output_ndarray);

Example:

$o = $rng->ran_binomial($p, $n,10,10);
$rng->ran_binomial($p, $n,$o);

ran_binomial does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_binomial_var

Signature: (p();n();[o]output(); gsl_rng *rng)

Similar to "ran_binomial" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_binomial_var($p_ndarray,$n_ndarray);

ran_binomial_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_negative_binomial

Signature: ([o]output(); double p; double n; gsl_rng *rng)

Fills output ndarray with random integer values from the negative binomial distribution, the number of failures occurring before $n successes in independent trials with probability $p of success. Note that $n is not required to be an integer.

Usage:

$ndarray = $rng->ran_negative_binomial($p, $n,[list of integers = output ndarray dims]);
$rng->ran_negative_binomial($p, $n, $output_ndarray);

Example:

$o = $rng->ran_negative_binomial($p, $n,10,10);
$rng->ran_negative_binomial($p, $n,$o);

ran_negative_binomial does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_negative_binomial_var

Signature: (p();n();[o]output(); gsl_rng *rng)

Similar to "ran_negative_binomial" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_negative_binomial_var($p_ndarray,$n_ndarray);

ran_negative_binomial_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_pascal

Signature: ([o]output(); double p; double n; gsl_rng *rng)

Fills output ndarray with random integer values from the Pascal distribution. The Pascal distribution is simply a negative binomial distribution (see "ran_negative_binomial") with an integer value of $n.

Usage:

$ndarray = $rng->ran_pascal($p, $n,[list of integers = output ndarray dims]);
$rng->ran_pascal($p, $n, $output_ndarray);

Example:

$o = $rng->ran_pascal($p, $n,10,10);
$rng->ran_pascal($p, $n,$o);

ran_pascal does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_pascal_var

Signature: (p();n();[o]output(); gsl_rng *rng)

Similar to "ran_pascal" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_pascal_var($p_ndarray,$n_ndarray);

ran_pascal_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_geometric

Signature: ([o]output(); double p; gsl_rng *rng)

Fills output ndarray with random integer values from the geometric distribution, the number of independent trials with probability $p until the first success.

Usage:

$ndarray = $rng->ran_geometric($p,[list of integers = output ndarray dims]);
$rng->ran_geometric($p, $output_ndarray);

Example:

$o = $rng->ran_geometric($p,10,10);
$rng->ran_geometric($p,$o);

ran_geometric does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_geometric_var

Signature: (p();[o]output(); gsl_rng *rng)

Similar to "ran_geometric" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_geometric_var($p_ndarray);

ran_geometric_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_hypergeometric

Signature: ([o]output(); double n1; double n2; double t; gsl_rng *rng)

Fills output ndarray with random integer values from the hypergeometric distribution. If a population contains $n1 elements of type 1 and $n2 elements of type 2 then the hypergeometric distribution gives the probability of obtaining $x elements of type 1 in $t samples from the population without replacement.

Usage:

$ndarray = $rng->ran_hypergeometric($n1, $n2, $t,[list of integers = output ndarray dims]);
$rng->ran_hypergeometric($n1, $n2, $t, $output_ndarray);

Example:

$o = $rng->ran_hypergeometric($n1, $n2, $t,10,10);
$rng->ran_hypergeometric($n1, $n2, $t,$o);

ran_hypergeometric does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_hypergeometric_var

Signature: (n1();n2();t();[o]output(); gsl_rng *rng)

Similar to "ran_hypergeometric" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_hypergeometric_var($n1_ndarray,$n2_ndarray,$t_ndarray);

ran_hypergeometric_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_logarithmic

Signature: ([o]output(); double p; gsl_rng *rng)

Fills output ndarray with random integer values from the logarithmic distribution.

Usage:

$ndarray = $rng->ran_logarithmic($p,[list of integers = output ndarray dims]);
$rng->ran_logarithmic($p, $output_ndarray);

Example:

$o = $rng->ran_logarithmic($p,10,10);
$rng->ran_logarithmic($p,$o);

ran_logarithmic does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_logarithmic_var

Signature: (p();[o]output(); gsl_rng *rng)

Similar to "ran_logarithmic" except that it takes the distribution parameters as an ndarray and returns an ndarray of equal dimensions.

Usage:

$ndarray = $rng->ran_logarithmic_var($p_ndarray);

ran_logarithmic_var does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_additive_gaussian

Signature: ([o]x(); double sigma; gsl_rng *rng)

Add Gaussian noise of given sigma to an ndarray.

Usage:

$rng->ran_additive_gaussian($sigma,$ndarray);

Example:

$rng->ran_additive_gaussian(1,$image);

ran_additive_gaussian does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_additive_poisson

Signature: ([o]x(); double sigma; gsl_rng *rng)

Add Poisson noise of given $mu to a $ndarray.

Usage:

$rng->ran_additive_poisson($mu,$ndarray);

Example:

$rng->ran_additive_poisson(1,$image);

ran_additive_poisson does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_feed_poisson

Signature: ([o]x(); gsl_rng *rng)

This method simulates shot noise, taking the values of ndarray as values for $mu to be fed in the poissonian RNG.

Usage:

$rng->ran_feed_poisson($ndarray);

Example:

$rng->ran_feed_poisson($image);

ran_feed_poisson does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_bivariate_gaussian

Signature: ([o]x(n); double sigma_x; double sigma_y; double rho; gsl_rng *rng)

Generates $n bivariate gaussian random deviates.

Usage:

$ndarray = $rng->ran_bivariate_gaussian($sigma_x,$sigma_y,$rho,$n);

Example:

$o = $rng->ran_bivariate_gaussian(1,2,0.5,1000);

ran_bivariate_gaussian does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_discrete

Signature: ([o]x(); gsl_ran_discrete_t *rng_discrete; gsl_rng *rng)

Is used to get the desired samples once a proper handle has been enstablished (see ran_discrete_preproc()).

Usage:

$ndarray = $rng->ran_discrete($discrete_dist_handle,$num);

Example:

$prob = pdl [0.1,0.3,0.6];
$ddh = $rng->ran_discrete_preproc($prob);
$o = $rng->ran_discrete($discrete_dist_handle,100);

ran_discrete does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_ver

Signature: ([o]x(n); double x0; double r;IV ns => n; gsl_rng *rng)

Returns an ndarray with $n values generated by the Verhulst map from $x0 and parameter $r.

Usage:

$rng->ran_ver($x0, $r, $n);

ran_ver does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

ran_caos

Signature: ([o]x(n); double m; IV ns => n; gsl_rng *rng)

Returns values from Verhuls map with $r=4.0 and randomly chosen $x0. The values are scaled by $m.

Usage:

$rng->ran_caos($m,$n);

ran_caos does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

BUGS

Feedback is welcome. Log bugs in the PDL bug database (the database is always linked from http://pdl.perl.org/).

SEE ALSO

PDL

The GSL documentation for random number distributions is online at https://www.gnu.org/software/gsl/doc/html/randist.html

AUTHOR

This file copyright (C) 1999 Christian Pellegrin <chri@infis.univ.trieste.it> Docs mangled by C. Soeller. All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation under certain conditions. For details, see the file COPYING in the PDL distribution. If this file is separated from the PDL distribution, the copyright notice should be included in the file.

The GSL RNG and randist modules were written by James Theiler.