|
Bsoft 2.1.4
Bernard's software package
|
Header file for functions for creating random images. More...
#include <Vector3.h>Functions | |
| long | get_rand_max () |
| Finds the maximum random number for a system. More... | |
| long | random_seed () |
| Gets a random seed and sets the flag. More... | |
| float * | random_array_uniform (long n, double min, double max) |
| Generates a series with a uniform random distribution. More... | |
| double | random_gaussian (double avg, double std) |
| Generates a value with a gaussian random distribution. More... | |
| float * | random_array_gaussian (long n, double avg, double std) |
| Generates a series with a gaussian random distribution of values. More... | |
| double | random_poisson (double avg) |
| Generates a value deviating from the average based on a poisson distribution. More... | |
| float * | random_array_poisson (int n, double avg) |
| Generates a series with a poisson random distribution of values. More... | |
| double | random_logistical (double avg, double std) |
| Generates a value with a logistical random distribution. More... | |
| float * | random_array_logistical (long n, double avg, double std) |
| Generates an array with a logistical random distribution. More... | |
| Vector3< double > | vector3_random_unit_sphere () |
| Generates a random vector on the unit sphere. More... | |
| Vector3< double > | vector3_random (const double min, const double max) |
| Generates a random vector within a defined cube. More... | |
| Vector3< double > | vector3_random (Vector3< double > min, Vector3< double > max) |
| Generates a random vector within a defined cube. More... | |
| Vector3< double > | vector3_random (const double length) |
| Generates a random vector within a defined sphere. More... | |
| Vector3< double > | vector3_random_gaussian (double avg, double std) |
| Generates a random vector within a random gaussian-distributed length. More... | |
| Vector3< double > | vector3_xy_random_gaussian (double avg, double std) |
| Generates a random vector within a random gaussian-distributed length in the xy plane. More... | |
Header file for functions for creating random images.
| long get_rand_max | ( | ) |
Finds the maximum random number for a system.
Loops through random numbers to determine if the maximum is 2 or 4 bytes.
| float * random_array_gaussian | ( | long | n, |
| double | avg, | ||
| double | stdev | ||
| ) |
Generates a series with a gaussian random distribution of values.
| n | number of values. |
| avg | average. |
| stdev | standard deviation. |
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.
| float * random_array_logistical | ( | long | n, |
| double | avg, | ||
| double | stdev | ||
| ) |
Generates an array with a logistical random distribution.
| n | number of values. |
| avg | average. |
| stdev | standard deviation. |
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. | float * random_array_poisson | ( | int | n, |
| double | avg | ||
| ) |
Generates a series with a poisson random distribution of values.
| n | number of values. |
| avg | average. |
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. | float * random_array_uniform | ( | long | n, |
| double | min, | ||
| double | max | ||
| ) |
Generates a series with a uniform random distribution.
| n | number of values. |
| min | minimum value. |
| max | maximum value. |
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).
| double random_gaussian | ( | double | avg, |
| double | stdev | ||
| ) |
Generates a value with a gaussian random distribution.
| avg | average. |
| stdev | standard deviation. |
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.
| double random_logistical | ( | double | avg, |
| double | stdev | ||
| ) |
Generates a value with a logistical random distribution.
| avg | average. |
| stdev | standard deviation. |
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. | double random_poisson | ( | double | avg | ) |
Generates a value deviating from the average based on a poisson distribution.
| avg | average. |
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. | long random_seed | ( | ) |
Gets a random seed and sets the flag.
The random seed is obtained using the program pid. A flag is set to prevent the seed from being generated multiple times.
| Vector3< double > vector3_random | ( | const double | length | ) |
Generates a random vector within a defined sphere.
| length | maximum vector length. |
A random vector is generated, normalized and multiplied with a random value smaller than the given length.
| Vector3< double > vector3_random | ( | const double | min, |
| const double | max | ||
| ) |
Generates a random vector within a defined cube.
| min | minimum. |
| max | maximum. |
Each vector element is set to a random value between the given minimum and maximum.
Generates a random vector within a defined cube.
| min | minimum vector. |
| max | maximum vector. |
Each vector element is set to a random value between the given minimum and maximum vectors.
| Vector3< double > vector3_random_gaussian | ( | double | avg, |
| double | stdev | ||
| ) |
Generates a random vector within a random gaussian-distributed length.
| avg | average of gaussian distribution. |
| stdev | standard deviation of gaussian distribution. |
A random vector is generated, normalized and multiplied with a random value derived from a gaussian distribution.
| Vector3< double > vector3_random_unit_sphere | ( | ) |
Generates a random vector on the unit sphere.
A random vector is generated with a uniform distribution on the unit sphere.Reference: Press W.H. et al (1992) Numerical Recipes in C.
| Vector3< double > vector3_xy_random_gaussian | ( | double | avg, |
| double | stdev | ||
| ) |
Generates a random vector within a random gaussian-distributed length in the xy plane.
| avg | average of gaussian distribution. |
| stdev | standard deviation of gaussian distribution. |
A random vector is generated, the z-component set to zero, normalized and multiplied with a random value derived from a gaussian distribution.