INTERFACE / PUBLIC COMPONENTS / NAMELIST / FILES / REFERENCES / ERRORS / BUGS / PLANS / PRIVATE COMPONENTS

MODULE random_seq_mod

Contact: Jeff Anderson
Reviewers:  
Revision: $Revision: 1.3 $
Release Name: $Name: iceland $
Change Date: $Date: 2005/02/22 16:31:58 $
Change history: see CVS log

OVERVIEW

Provides access to any number of reproducible random sequences and allows uniform, gaussian, and two-dimensional gaussian distributions to be sampled.




OTHER MODULES USED

types_mod
utilities_mod
random_nr_mod



PUBLIC INTERFACE

use assim_model_mod, only : random_seq_type
 init_random_seq
 random_gaussian
 several_random_gaussians
 random_uniform
 twod_gaussians

NOTES




PUBLIC COMPONENTS




type random_seq_type
   private
end type random_seq_type

Description

This type is used to uniquely identify a sequence. In this implementation, it is passed through directly from the random_nr_mod and details can be seen in that module.


call init_random_seq(r)
 type(random_seq_type), intent(inout) :: r
 

Description

Initializes a random sequence for use. This must be called before any random numbers can be generated from this sequence. Any number of independent, reproducible random sequences can be generated by having multiple instances of a random_seq_type.

r    A random sequence.


var = random_gaussian(r, mean, standard_deviation)
 real(r8)                             :: random_gaussian
 type(random_seq_type), intent(inout) :: r
 real(r8), intent(in)                 :: mean
 real(r8), intent(in)                 :: standard_deviation
 

Description

Returns a random draw from a Gaussian distribution with mean and standard deviation.

random_gaussian    A random draw from a gaussian distribution.
r    The reproducible random sequence.
mean    Mean of the gaussian.
standard_deviation    Standard deviation of the gaussian.


call several_random_gaussians(r, mean, standard_deviation, n, rnum)
 type(random_seq_type), intent(inout) :: r
 real(r8), intent(in)                 :: mean
 real(r8), intent(in)                 :: standard_deviation
 integer, intent(in)                  :: n
 real(r8), intent(out), dimension(:)  :: rnum
 

Description

Returns n random samples from a gaussian with mean and standard deviation. Make sure that there is enough room in rnum for all the returned values.

r    A reproducible random sequence.
mean    Mean of the Gaussian to be sampled.
standard_deviation    Standard deviation of the Gaussian.
n    Number of samples to return
rnum    The random samples of the Gaussian.


var = random_uniform(r)
 real(r8)                             :: random_uniform
 type(random_seq_type), intent(inout) :: r
 

Description

Returns a random draw from a uniform distribution on interval [0,1].

random_uniform    A random draw from a Uniform[0,1] distribution.
r    A random sequence.


call twod_gaussians(r,mean,cov,rnum)
 type(random_seq_type), intent(inout)  :: r
 real(r8), dimension(2), intent(in)    :: mean
 real(r8), dimension(2, 2), intent(in) :: cov
 real(r8), dimension(2), intent(out)   :: rnum
 

Description

Returns a random draw from a 2D gaussian with mean and covariance. The algorithm used is from Knuth, exercise 13, section 3.4.1.

r    A random sequence.
mean    Mean of 2D gaussian distribution.
cov    Covariance of 2D gaussian.
rnum    Returned random draw from gaussian.




FILES




REFERENCES


ERROR CODES and CONDITIONS




KNOWN BUGS