/Users/bernard/b20/bsoft/include/random_numbers.h(3)

NAME
/Users/bernard/b20/bsoft/include/random_numbers.h - Header file for functions for creating random images.

SYNOPSIS

#include <Vector3.h>

  Functions
long get_rand_max ()
Finds the maximum random number for a system.
long random_seed ()
Gets a random seed and sets the flag.
float * random_array_uniform (long n, double min, double max)
Generates a series with a uniform random distribution.
double random_gaussian (double avg, double std)
Generates a value with a gaussian random distribution.
float * random_array_gaussian (long n, double avg, double std)
Generates a series with a gaussian random distribution of values.
double random_poisson (double avg)
Generates a value deviating from the average based on a poisson distribution.
float * random_array_poisson (int n, double avg)
Generates a series with a poisson random distribution of values.
double random_logistical (double avg, double std)
Generates a value with a logistical random distribution.
float * random_array_logistical (long n, double avg, double std)
Generates an array with a logistical random distribution.
Vector3< double > vector3_random_unit_sphere ()
Generates a random vector on the unit sphere.
Vector3< double > vector3_random (const double min, const double max)
Generates a random vector within a defined cube.
Vector3< double > vector3_random (Vector3< double > min, Vector3< double > max)
Generates a random vector within a defined cube.
Vector3< double > vector3_random (const double length)
Generates a random vector within a defined sphere.
Vector3< double > vector3_random_gaussian (double avg, double std)
Generates a random vector within a random gaussian-distributed length.
Vector3< double > vector3_xy_random_gaussian (double avg, double std)
Generates a random vector within a random gaussian-distributed length in the xy plane.

Detailed Description

Header file for functions for creating random images.

Author:
    Bernard Heymann

Date:
    Created: 19990703

    Modified: 20151113

Definition in file random_numbers.h.

Function Documentation

  long get_rand_max ()

Finds the maximum random number for a system.

Returns:
    long the maximum random number.

    Loops through random numbers to determine if the maximum is 2 or 4 bytes.

Definition at line 22 of file random_numbers.cpp.

  float* random_array_gaussian (long n, double avg, double stdev)

Generates a series with a gaussian random distribution of values.

Parameters:
    n number of values.
    avg average.
    stdev standard deviation.

Returns:
    float* the array of values.

    An array of floating point numbers is generated with a gaussian
    distribution with a given average and standard deviation:
        value = average + std_dev*sqrt(-2*log(random_value))*
                        cos(2*PI*random_value);
    where random_value is between 0 and 1.

Definition at line 172 of file random_numbers.cpp.

  float* random_array_logistical (long n, double avg, double stdev)

Generates an array with a logistical random distribution.

Parameters:
    n number of values.
    avg average.
    stdev standard deviation.

Returns:
    float* array of values.

    An array of floating point numbers is generated with a logistical
    differential distribution with a given average and standard deviation:
        value = average + (std_dev/golden)*ln(1/random_value - 1)
    where random_value is between 0 and 1 and:
        golden  = (sqrt(5) + 1)/2

     Reference: Press W.H. et al (1992) Numerical Recipes in C.

Definition at line 379 of file random_numbers.cpp.

  float* random_array_poisson (int n, double avg)

Generates a series with a poisson random distribution of values.

Parameters:
    n number of values.
    avg average.

Returns:
    float* the array of values.

    The poisson distribution is given for j = 0,1,... by:
                avg^j * exp(-avg)
        P(j) = -----------------
                       j!
    Note that only positive integer values are defined for j and sum(P(j)) = 1.
    An array of floating point numbers is generated with a poisson
    distribution with a given average. The standard deviation is:
        std = sqrt(avg)
    If the average <= 0, the return array contains only zeroes.

     Reference: Press W.H. et al (1992) Numerical Recipes in C.

Definition at line 296 of file random_numbers.cpp.

  float* random_array_uniform (long n, double min, double max)

Generates a series with a uniform random distribution.

Parameters:
    n number of values.
    min minimum value.
    max maximum value.

Returns:
    float* array with uniform random numbers.

    An array of floating point numbers is generated distributed uniformly
    in the range of the given minimum and maximum:
        value = random_value*(max - min) + min
    where random_value is between 0 and 1.
    The average and standard deviation are:
        average = (max + min)/2
        standard deviation = 0.5*sqrt(1/3)*(max - min).

Definition at line 76 of file random_numbers.cpp.

  double random_gaussian (double avg, double stdev)

Generates a value with a gaussian random distribution.

Parameters:
    avg average.
    stdev standard deviation.

Returns:
    double the random value.

    A floating point number is generated with a gaussian
    distribution with a given average and standard deviation:
        value = average + std_dev*sqrt(-2*log(random_value))*
                        cos(2*PI*random_value);
    where random_value is between 0 and 1.

Definition at line 123 of file random_numbers.cpp.

  double random_logistical (double avg, double stdev)

Generates a value with a logistical random distribution.

Parameters:
    avg average.
    stdev standard deviation.

Returns:
    double the random value.

    A floating point number is generated with a logistical
    differential distribution with a given average and standard deviation:
        value = average + (std_dev/golden)*ln(1/random_value - 1)
    where random_value is between 0 and 1 and:
        golden  = (sqrt(5) + 1)/2

     Reference: Press W.H. et al (1992) Numerical Recipes in C.

Definition at line 338 of file random_numbers.cpp.

  double random_poisson (double avg)

Generates a value deviating from the average based on a poisson distribution.

Parameters:
    avg average.

Returns:
    double value.

    The poisson distribution is given for j = 0,1,... by:
                avg^j * exp(-avg)
        P(j) = -----------------
                       j!
    Note that only positive integer values are defined for j and sum(P(j)) = 1.
    A value is generated with a poisson distribution with a given average.
    If the average <= 0, the return value is zero.

     Reference: Press W.H. et al (1992) Numerical Recipes in C.

Definition at line 221 of file random_numbers.cpp.

  long random_seed ()

Gets a random seed and sets the flag.

Returns:
    int flag.

    The random seed is obtained using the program pid.
    A flag is set to prevent the seed from being generated multiple times.

Definition at line 41 of file random_numbers.cpp.

  Vector3<double> vector3_random (const double min, const double max)

Generates a random vector within a defined cube.

Parameters:
    min minimum.
    max maximum.

Returns:
    Vector3<double> vector.

    Each vector element is set to a random value between the given minimum and maximum.

Definition at line 440 of file random_numbers.cpp.

  Vector3<double> vector3_random (Vector3< double > min, Vector3< double > max)

Generates a random vector within a defined cube.

Parameters:
    min minimum vector.
    max maximum vector.

Returns:
    Vector3<double> vector.

    Each vector element is set to a random value between the given
    minimum and maximum vectors.

Definition at line 462 of file random_numbers.cpp.

  Vector3<double> vector3_random (const double length)

Generates a random vector within a defined sphere.

Parameters:
    length maximum vector length.

Returns:
    Vector3<double> vector.

    A random vector is generated, normalized and multiplied with
    a random value smaller than the given length.

Definition at line 483 of file random_numbers.cpp.

  Vector3<double> vector3_random_gaussian (double avg, double stdev)

Generates a random vector within a random gaussian-distributed length.

Parameters:
    avg average of gaussian distribution.
    stdev standard deviation of gaussian distribution.

Returns:
    Vector3<double> vector.

    A random vector is generated, normalized and multiplied with
    a random value derived from a gaussian distribution.

Definition at line 502 of file random_numbers.cpp.

  Vector3<double> vector3_random_unit_sphere ()

Generates a random vector on the unit sphere.

Returns:
    Vector3<double> vector.

    A random vector is generated with a uniform distribution on the unit sphere.

     Reference: Press W.H. et al (1992) Numerical Recipes in C.

Definition at line 419 of file random_numbers.cpp.

  Vector3<double> vector3_xy_random_gaussian (double avg, double stdev)

Generates a random vector within a random gaussian-distributed length in the xy plane.

Parameters:
    avg average of gaussian distribution.
    stdev standard deviation of gaussian distribution.

Returns:
    Vector3<double> vector.

    A random vector is generated, the z-component set to zero, normalized
    and multiplied with a random value derived from a gaussian distribution.

Definition at line 522 of file random_numbers.cpp.

Author

Generated automatically by Doxygen for Bsoft from the source code.