rged Generalized Error Distribution generator uses sign(runif)

Michael Stevens mail at michael-stevens.de
Sun Dec 19 10:59:14 CET 2010


Hello Rmetric,

I have been asked to implement an Generalized Error Distribution in Java 
for a project. As the basis for this I looked at rged and rsged in the 
Rmetrics.

While analysing the code I found a couple of problems which I would like 
to give the authors some feedback on. Most importantly I think the use 
of sign(runif) is incorrect. For example in the implementation of rged

z = lambda * (2 * r)^(1/nu) * sign(runif(n) - 1/2)

sign(runif(n) - 1/2) may return 0. However the probablity that this will 
occur is only related to the precision of the internal PRNG and the 
floating point representation.

I suspect what is is required is a random function which return only -1 
and 1 with equal probability. Sadly I do not think this can be correctly 
directly with runif. If we map >=0 to 1 and <0 to -1 then 1 will be 
slightly more likely then -1. The simplest solution would be to reject 0 
and try again. Better would be to work directly with an integer PRNG. 
Does such a thing exist in R?

In .rsged there is a similar problem with
     z = runif(n, -weight, 1 - weight)
     Xi = xi^sign(z)

Also the value of g
  g = nu/(lambda * (2^(1 + 1/nu)) * gamma(1/nu))
is never used in .rsged.

I hope this helps,


___________________________________
Michael Stevens Systems Engineering

34128 Kassel, Germany
Phone/Fax: +49 561 5603097
Mobile: +49 1577 7807325

Navigation Systems, Estimation  and
                  Bayesian Filtering
     http://bayesclasses.sf.net



More information about the Rmetrics-core mailing list