rnorm_vec Function

public function rnorm_vec(n, mu, sigma) result(variates)

Vector of reals that follow a normal law

source

authors: Beliavsky, Miller

Arguments

Type IntentOptional 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

Return Value real(kind=R8), dimension(1:n)

output vector


Calls

proc~~rnorm_vec~~CallsGraph proc~rnorm_vec rnorm_vec proc~rnorm rnorm proc~rnorm_vec->proc~rnorm

Called by

proc~~rnorm_vec~~CalledByGraph proc~rnorm_vec rnorm_vec program~test_stat test_stat program~test_stat->proc~rnorm_vec

Source Code

   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