chsran(3f) - [M_datapac:RANDOM] generate chi-square random numbers
Synopsis
Description
Input Arguments
Output Arguments
Examples
Author
Maintainer
License
References
SUBROUTINE CHSRAN(N,Nu,Iseed,X)
INTEGER,intent(in) :: N INTEGER,intent(in) :: Nu INTEGER,intent(inout) :: Iseed REAL(kind=wp),intent(out) :: X(:)
CHSRAN(3f) generates a random sample of size n from the chi-squared distribution with integer degrees of freedom parameter = NU.
N The desired integer number of random numbers to be generated. NU The integer degrees of freedom (parameter) for the chi-squared distribution. NU should be a positive integer variable. 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.
--X A vector (of dimension at least N) into which the generated random sample of size N from the chi-squared distribution will be placed.
Sample program:
program demo_chsran use m_datapac, only : chsran, plott, label, plotxt, sort implicit none integer,parameter :: n=4000 integer :: iseed integer :: Nu real :: x(n) call label(chsran) Nu=8 iseed=12345 call chsran(N,Nu,Iseed,X) call plotxt(x,n) call sort(x,n,x) ! sort to show distribution call plotxt(x,n) end program demo_chsranResults:
THE FOLLOWING IS A PLOT OF X(I) (VERTICALLY) VERSUS I (HORIZONTALLY I-----------I-----------I-----------I-----------I 0.3098298E+02 - X 0.2972390E+02 I 0.2846483E+02 I 0.2720575E+02 I X 0.2594668E+02 I X X 0.2468760E+02 I 0.2342853E+02 - X X X 0.2216945E+02 I X X X X X X 0.2091037E+02 I X X X X X XX X X XX X 0.1965130E+02 I XXX XX X XX X XXX X XX X XX X 0.1839222E+02 I XXX X X XXXXXXX XXX XXX XXXX XX X X X XXX 0.1713315E+02 I XX X XXX XX XXXX XXXXX XXXX XXX XXXXX XXX XX 0.1587407E+02 - XXXXXX XXXXXX XX XXXX XX XXX X XX XXXX XX XXXX 0.1461500E+02 I XXXXXXXXX XX XXXXXXXXX XX XXX XXXXXX X XXXXXXXX 0.1335592E+02 I X XXXXX XXXXXXX XXX XXX XX XXXXXXX XXXXXXXX XXXX 0.1209685E+02 I XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 0.1083777E+02 I XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 0.9578695E+01 I XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 0.8319620E+01 - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 0.7060543E+01 I XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 0.5801468E+01 I XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 0.4542393E+01 I XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 0.3283318E+01 I XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 0.2024242E+01 I XXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 0.7651675E+00 - X X X X XX X XXX X XX X I-----------I-----------I-----------I-----------I 0.1000E+01 0.1001E+04 0.2000E+04 0.3000E+04 0.4000E+04THE FOLLOWING IS A PLOT OF X(I) (VERTICALLY) VERSUS I (HORIZONTALLY I-----------I-----------I-----------I-----------I 0.3098298E+02 - X 0.2972390E+02 I 0.2846483E+02 I 0.2720575E+02 I X 0.2594668E+02 I X 0.2468760E+02 I 0.2342853E+02 - X 0.2216945E+02 I X 0.2091037E+02 I X 0.1965130E+02 I XX 0.1839222E+02 I X 0.1713315E+02 I XX 0.1587407E+02 - XX 0.1461500E+02 I XX 0.1335592E+02 I XXX 0.1209685E+02 I XXXX 0.1083777E+02 I XXXX 0.9578695E+01 I XXXXXX 0.8319620E+01 - XXXXXX 0.7060543E+01 I XXXXXXXX 0.5801468E+01 I XXXXXXX 0.4542393E+01 I XXXXXXX 0.3283318E+01 I XXXXXX 0.2024242E+01 I XXX 0.7651675E+00 - X I-----------I-----------I-----------I-----------I 0.1000E+01 0.1001E+04 0.2000E+04 0.3000E+04 0.4000E+04
The original DATAPAC library was written by James Filliben of the Statistical Engineering Division, National Institute of Standards and Technology.
John Urban, 2022.05.31
CC0-1.0
o Tocher, The Art of Simulation, 1963, pages 34-35. o Mood and Grable, Introduction to the Theory of Statistics, 1963, pages 226-227. o Johnson and Kotz, Continuous Univariate Distributions--1, 1970, page 171. o Hastings and Peacock, Statistical Distributions--A Handbook for Students and Practitioners, 1975, page 48.
Nemo Release 3.1 | chsran (3) | February 23, 2025 |