box_muller_sample Interface

public interface box_muller_sample

Generates random, normally distributed values via the Box-Muller transform.


Contents


Module Procedures

private function box_muller_sample_scalar(mu, sigma) result(rst)

Generates a pair of independent, standard, normally distributed random values using the Box-Muller transform.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: mu

The mean of the distribution.

real(kind=real64), intent(in) :: sigma

The standard deviation of the distribution.

Return Value real(kind=real64), (2)

The pair of random values.

private function box_muller_array(mu, sigma, n) result(rst)

Generates an array of normally distributed random values sampled by the Box-Muller transform.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: mu

The mean of the distribution.

real(kind=real64), intent(in) :: sigma

The standard deviation of the distribution.

integer(kind=int32), intent(in) :: n

The number of Box-Muller pairs to generate.

Return Value real(kind=real64), allocatable, dimension(:)

A 2N-element array containing the N Box-Muller pairs.