The R Project SVN R

Rev

Rev 85983 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 85983 Rev 86023
Line 1... Line 1...
1
% File src/library/datasets/man/randu.Rd
1
% File src/library/datasets/man/randu.Rd
2
% Part of the R package, https://www.R-project.org
2
% Part of the R package, https://www.R-project.org
3
% Copyright 1995-2007 R Core Team
3
% Copyright 1995-2024 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{randu}
6
\name{randu}
7
\docType{data}
7
\docType{data}
8
\alias{randu}
8
\alias{randu}
Line 30... Line 30...
30
}
30
}
31
\source{
31
\source{
32
  David Donoho
32
  David Donoho
33
}
33
}
34
\examples{
34
\examples{
35
\donttest{## We could re-generate the dataset by the following R code
35
## We could re-generate the dataset by the following R code
36
seed <- as.double(1)
36
seed <- as.double(1)
37
RANDU <- function() {
37
RANDU <- function() {
38
    seed <<- ((2^16 + 3) * seed) \%\% (2^31)
38
    seed <<- ((2^16 + 3) * seed) \%\% (2^31)
39
    seed/(2^31)
39
    seed/(2^31)
40
}
40
}
-
 
41
myrandu <- matrix(NA_real_, 400, 3, dimnames = list(NULL, c("x","y","z")))
41
for(i in 1:400) {
42
for(i in 1:400) {
42
    U <- c(RANDU(), RANDU(), RANDU(), RANDU(), RANDU())
43
    U <- c(RANDU(), RANDU(), RANDU(), RANDU(), RANDU())
43
    print(round(U[1:3], 6))
44
    myrandu[i,] <- round(U[1:3], 6)
44
}}
45
}
-
 
46
stopifnot(all.equal(randu, as.data.frame(myrandu), tolerance = 1e-5))
45
}
47
}
46
\keyword{datasets}
48
\keyword{datasets}