Vector of reals that follow a normal law
authors: Beliavsky, Miller
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I4), | intent(in) | :: | n |
vector size |
||
real(kind=R8), | intent(in), | optional | :: | mu |
distribution mean |
|
real(kind=R8), | intent(in), | optional | :: | sigma |
distribution std |
output vector
function rnorm_vec(n, mu, sigma) result(variates) !================================================================================================ !! Vector of reals that follow a normal law !! !! [source](https://fortran-lang.discourse.group/t/normal-random-number-generator/3724/2) !! !! authors: Beliavsky, Miller !------------------------------------------------------------------------------------------------ integer(kind=I4), intent(in ) :: n !! *vector size* real (kind=R8), intent(in ), optional :: mu !! *distribution mean* real (kind=R8), intent(in) , optional :: sigma !! *distribution std* real (kind=R8), dimension(1:n) :: variates !! *output vector* integer(kind=I4) :: i do i = 1, n variates(i) = rnorm() enddo if ( present(sigma) ) variates = sigma*variates if ( present(mu) ) variates = variates + mu return endfunction rnorm_vec