File: 4A-PortableInnovations.Rd

package info (click to toggle)
fbasics 240.10067-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,676 kB
  • ctags: 760
  • sloc: fortran: 5,589; sh: 22; makefile: 1
file content (127 lines) | stat: -rw-r--r-- 2,706 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
\name{PortableRandomInnovations}

\alias{PortableRandomInnovations}

\alias{set.lcgseed}
\alias{get.lcgseed}
\alias{runif.lcg}
\alias{rnorm.lcg}
\alias{rt.lcg}

\title{Generator for Portable Random Innovations}


\description{

    A collection and description of functions to 
    generate portable random innovations. The 
    functions run under R and S-Plus and generate 
    the same sequence of random numbers. Supported 
    are uniform, normal and Student-t distributed 
    random numbers.
    \cr
        
    The functions are:
    
    \tabular{ll}{
    \code{set.lcgseed} \tab Set initial random seed, \cr
    \code{get.lcgseed} \tab Get the current valus of the random seed, \cr
    \code{runif.lcg} \tab Uniform linear congruational generator, \cr
    \code{rnorm.lcg} \tab Normal linear congruational generator, \cr
    \code{rt.lcg} \tab Student-t linear congruential generator. }
    
}


\usage{
set.lcgseed(seed = 4711)
get.lcgseed()
runif.lcg(n, min = 0, max = 1)
rnorm.lcg(n, mean = 0, sd = 1)
rt.lcg(n, df)   
}


\arguments{

    \item{df}{
        number of degrees of freedom, a positive integer, maybe 
        non-integer.
        }
    \item{mean, sd}{
        means and standard deviation of the normal distributed 
        innovations.
        }
    \item{min, max}{
        lower and upper limits of the uniform distributed 
        innovations.
        }
    \item{seed}{
        an integer value, the random number seed.
        }
    \item{n}{
        an integer, the number of random innovations to be 
        generated.
        }
            
}


\details{
    
    A simple portable random number generator for use in R and 
    SPlus. We recommend to use this generator only for comparisons 
    of calculations in R and Splus.

    The generator is a linear congruential generator with parameters
    \code{LCG(a=13445, c=0, m=2^31-1, X=0)}. It is a simple random 
    number generator which passes the bitwise randomness test.

}


\value{

    A vector of generated random innovations. The value of the
    current seed is stored in the variable \code{lcg.seed}.
    
}


\references{

Altman, N.S. (1988);
    \emph{Bitwise Behavior of Random Number Generators},
     SIAM J. Sci. Stat. Comput., 9(5), September, 941--949.

}


\author{

    Diethelm Wuertz for the Rmetrics \R-port.
    
}


\examples{
## SOURCE("fSeries.4A-PortableRandomInnovations")

## set.lcgseed -
   set.lcgseed(seed = 65890)
 
## runif.lcg - rnorm.lcg - rt.lcg -
   cbind(runif.lcg(10), rnorm.lcg(10), rt.lcg(10, df = 4))

## get.lcgseed -
   get.lcgseed()  
   
## Note, to overwrite rnorm, use
   # rnorm = rnorm.lcg
   # Going back to rnorm
   # rm(rnorm)
}


\keyword{programming}