Manual Reference Pages  - norran (3m_datapac)

NAME

norran(3f) - [M_datapac:RANDOM] generate normal random numbers

CONTENTS

Synopsis
Description
Input Arguments
Output Arguments
Examples
Author
Maintainer
License
References

SYNOPSIS

SUBROUTINE NORRAN(N,Iseed,X)

       INTEGER,integer(in)        :: N
       INTEGER,integer(inout)     :: Iseed
       REAL(kind=wp),integer(out) :: X(:)

DESCRIPTION

NORRAN(3f) generates a random sample of size N from the normal (Gaussian) distribution with mean = 0 and standard deviation = 1.

Internally, it uses the Box-Muller algorithm.

This distribution is defined for all X and has the probability density function

       f(X) = (1/sqrt(2*pi))*exp(-X*X/2)

INPUT ARGUMENTS

N The desired integer number of random numbers to be generated.

ISEED An integer seed value. Should be set to a non-negative value to start a new sequence of values. Will be set to -1 on return to indicate the next call should continue the current random sequence walk.

OUTPUT ARGUMENTS

X A vector (of dimension at least N) into which the generated random sample of size N from the normal distribution with mean = 0 and standard deviation = 1 will be placed.

EXAMPLES

Sample program:

   program demo_norran
   use M_datapac, only : norran, label, plotxt, sort, norplt, plott
   implicit none
   integer,parameter :: N=300
   real              :: x(N), y(N)
   real              :: mu, sigma
   integer           :: Iseed
   integer           :: i
      Iseed=1234
      sigma=1.00000
      mu=0.0
      call label(’norran’)
      call norran(N,Iseed,x)
      x = sigma*x
      x = x + mu
      call plotxt(x,n)
      call sort(x,n,y) ! sort and replot to better discern distribution
      call plott([(real(i),i=1,n)],y,n)
   end program demo_norran

Results:

    THE FOLLOWING IS A PLOT OF X(I) (VERTICALLY) VERSUS I (HORIZONTALLY
                      I-----------I-----------I-----------I-----------I
     0.3016713E+01 -                                               X
     0.2787551E+01 I
     0.2558388E+01 I
     0.2329226E+01 I     X
     0.2100063E+01 I
     0.1870901E+01 I     X   X XX      X XX      XX X
     0.1641738E+01 -         X    X         X
     0.1412575E+01 I    X        X X X  XX       X  X X         X
     0.1183413E+01 I                     X X        XX    X XXX   XX
     0.9542503E+00 I    X   XX          X             X    X  XX X X
     0.7250879E+00 I   X  XX X      X  X        XXX      XX     X X X
     0.4959254E+00 I     XX X  XXX   XXXXX   X  XX    X    X XX  XX  X
     0.2667627E+00 -    X XX  XXX X   XXX X X XX   X XXXX X  X     XX
     0.3760028E-01 I   X X    X   XX XXX  X   XXX X  X XXXX XX XX X  XX
    -0.1915622E+00 I  XX  X   X  X   X   X X X  X XXXX XX  XX X  X   X
    -0.4207249E+00 I  XX  XX   XX XXXX X   XX XX   X XXXX X X XXX XXX
    -0.6498873E+00 I        X XXX  XX  XX    XXXXXX    X XX    X     XX
    -0.8790498E+00 I   XX  X X   X  X X    XXX      X   X  XX       XX
    -0.1108212E+01 -        X     XXX     XXX  X         X        X
    -0.1337375E+01 I  X X    X                 X       X X   X XX X X
    -0.1566537E+01 I    X X          X       X               XX
    -0.1795700E+01 I  X    X   X   XX        X                        X
    -0.2024862E+01 I        X  X      X
    -0.2254025E+01 I                                     X         XX
    -0.2483188E+01 -            X
                      I-----------I-----------I-----------I-----------I
               0.1000E+01  0.7575E+02  0.1505E+03  0.2252E+03  0.3000E+03

The following is a plot of Y(I) (vertically) versus X(I) (horizontally) I-----------I-----------I-----------I-----------I 0.3000000E+03 - XX X X 0.2875417E+03 I XXXXX 0.2750833E+03 I XXX 0.2626250E+03 I XXX 0.2501667E+03 I XXX 0.2377083E+03 I XX 0.2252500E+03 - XXX 0.2127917E+03 I X 0.2003333E+03 I XX 0.1878750E+03 I XX 0.1754167E+03 I XX 0.1629583E+03 I X 0.1505000E+03 - XX 0.1380417E+03 I XX 0.1255833E+03 I XX 0.1131250E+03 I XX 0.1006667E+03 I X 0.8820834E+02 I XX 0.7575000E+02 - X 0.6329167E+02 I XX 0.5083334E+02 I XX 0.3837500E+02 I XX 0.2591669E+02 I XXX 0.1345834E+02 I XXXXX 0.1000000E+01 - X X XX I-----------I-----------I-----------I-----------I -0.2483E+01 -0.1108E+01 0.2668E+00 0.1642E+01 0.3017E+01

AUTHOR

The original DATAPAC library was written by James Filliben of the Statistical Engineering Division, National Institute of Standards and Technology.

MAINTAINER

John Urban, 2022.05.31

LICENSE

CC0-1.0

REFERENCES

o Box and Muller, ’A Note on the Generation of Random Normal Deviates’, Journal of the Association for Computing Machinery, 1958, pages 610-611.
o Tocher, The Art of Simulation, 1963, pages 33-34.
o Hammersley and Handscomb, Monte Carlo Methods, 1964, page 39.
o Johnson and Kotz, Continuous Univariate Distributions--1, 1970, pages 40-111.


Nemo Release 3.1 norran (3m_datapac) July 20, 2023
Generated by manServer 1.08 from d051e040-2673-4d22-a52e-37479b2f9cc1 using man macros.