Contact: | Jeff Anderson |
Reviewers: | |
Revision: | $Revision: 1.2 $ |
Release Name: | $Name: pre_hawaii $ |
Change Date: | $Date: 2004/12/22 20:48:13 $ |
Change history: | see CVS log |
Provides access to any number of reproducible random sequences and allows uniform, gaussian, and two-dimensional gaussian distributions to be sampled.
types_mod utilities_mod random_nr_mod
use assim_model_mod, only : | random_seq_type |
init_random_seq | |
random_gaussian | |
several_random_gaussians | |
random_uniform | |
twod_gaussians |
type random_seq_type private end type random_seq_type
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.
type(random_seq_type), intent(inout) :: r
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. |
real(r8) :: random_gaussian type(random_seq_type), intent(inout) :: r real(r8), intent(in) :: mean real(r8), intent(in) :: standard_deviation
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. |
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
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. |
real(r8) :: random_uniform type(random_seq_type), intent(inout) :: r
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. |
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
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. |