randn1d Function

private function randn1d(n) result(r)

Generates n random numbers with a normal distribution.

Arguments

Type IntentOptional AttributesName
integer(kind=ik), intent(in) :: n

Return Value real(kind=rk) (n)


Called by

proc~~randn1d~~CalledByGraph proc~randn1d randn1d interface~randn randn interface~randn->proc~randn1d proc~constructor constructor proc~constructor->interface~randn interface~layer_type layer_type interface~layer_type->proc~constructor

Contents

Source Code


Source Code

  function randn1d(n) result(r)
    !! Generates n random numbers with a normal distribution.
    integer(ik), intent(in) :: n
    real(rk) :: r(n), r2(n)
    call random_number(r)
    call random_number(r2)
    r = sqrt(-2 * log(r)) * cos(2 * pi * r2)
  end function randn1d