DIPlib Documentation - ©1995-2009 Quantitative Imaging Group, Delft University of Technology.

RandomVariable

Random number generator

SYNOPSIS

include "dip_noise.h"

dip_Error dip_RandomVariable ( random, value )

FUNCTION

Generates a random number between zero and one.

This function is based on the Numerical Recipes' RAN1 function. The dip_Random structure can be initialized with the function dip_RandomSeed. If the supplied dip_Random structure is not initialized, dip_RandomVariable will initialize the dip_Random structure with a seed equal to zero. To guarantee the (psuedo) randomness between variables obtained with subsequent calls to dip_RandomVariable (or to functions that use this function to obtain a random variable), a pointer to the same dip_Random structure has to supplied when calling dip_RandomVariable.

ARGUMENTS

Data typeNameDescription
dip_Random *randomPointer to a random value structure
dip_float *valuevalue

EXAMPLE

Obtain a random number as follows:

   dip_Random random;
   dip_float val;

   DIPXX(dip_RandomVariable( &random, &val));

SEE ALSO

RandomSeed, UniformRandomVariable, GaussianRandomVariable, PoissonRandomVariable, BinaryRandomVariable

DIPlib on-line documentation | Function reference | Global function index