[Rd] Random number generation problem (PR#554)

Prof Brian D Ripley ripley@stats.ox.ac.uk
Tue, 23 May 2000 20:03:30 +0100 (BST)


On Tue, 23 May 2000 kjetikj@astro.uio.no wrote:

> Full_Name: Kjetil Kjernsmo
> Version: 1.0.1
> OS: osf1
> Submission from: (NULL) (129.240.28.227)
> 
> 
> Hello!
> 
> I'm getting strange numbers from a random number generation 
> function again. I was wondering if it could be the same problem 
> as I reported in (PR#439). 
> 
> I'm using the functions (some comments deleted for brevity):
> 
> qamp <- function(p,  type=c("point", "nolens"))
> {
>   if(type == "point")  
>     return(1 / (2 * sqrt(1 - p)))
>   else return(1)
> }
>   
> ramp <- function(n, type=c("point", "nolens"))
> {
>   if(type == "point")
>     return(qamp(runif(n), type))
>   else return(rep(1, n))
> }
> 
> ...to generate random numbers. I think there might be something wrong
> with runif, possibly the same problem as rpois had. 

Not at all, that problem is fixed.

> More details:
> I'm calling this function a number of times through a function
> intensityfromcloud <- function(ncloudsbin, cloudintensity, amptype,
>                                exptime, ...)
> {
>   amps <- ramp(ncloudsbin, amptype)
>   write(c(max(amps), sum(amps), sum(amps - 1)),
>         "lastamps.dat", ncolumns=3, append=T)
>   return(cloudintensity * exptime * amps)
> }
> ...that is called a lot. As you can see, I'm writing the maximum 
> (among other things) of the generated numbers to file 
> (this is a preliminary hack, for a (quite unrelated) sanity 
> check I'm running). 
> Now, it turns out that in 8080 maxima, the number 14654.29 appears
> twice. Things like that happen, this _is_ statistics,
> and my pdf doesn't fall that fast, but you know...
> I thought I'd report this sooner the better... 

And which random number generator are you using?  And have you a proven
stable procedure based on its results?  (Doesn't look like it, I have to
say.)

Please do read the advice in the FAQ on reporting a bug. There is 
npthing here that I can see is a bug, or see how to investigate.
All PRNGs have deficiencies, and you have to program procedures to take
account of them.  R provides several alternatives for you to try out.
Do make use of them!

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._