[Rd] Error in FrF2 example on Mac OS

Ulrike Grömping groemp at tfh-berlin.de
Wed Mar 25 07:50:01 CET 2009




Petr Savicky wrote:
> 
> On Tue, Mar 24, 2009 at 07:41:31AM -0700, Ulrike Grömping wrote:
>> > Probably, k is needed also later. Assumig that 2^k works correctly,
>> > the following could be sufficient
>> > 
>> >    if (!is.null(nruns)){
>> >       k <- round(log2(nruns))
>> >       if (!2^k==nruns) stop("nruns must be a power of 2.")}
>> > 
>> > In order to test the assumption, one can use
>> > 
>> >   x <- 2^(0:100 + 0) # use double exponent to be sure
>> >   all(x == floor(x))
>> > 
>> > Powers of two are represented exactly, since they have only one
>> > significant bit.
>> > 
>> > Petr.
>> > 
>> 
>> Yes, round instead of floor should also do the job, if rounding is the
>> issue. But then, with powers of 2 indeed being represented exactly (I
>> would
>> expect even on Macs), maybe rounding is not the issue? I have no
>> possibility
>> to check this, since I do not have access to a Mac with R installed. On
>> my
>> windows machine, 
>> all(log2(x)==floor(log2(x))) 
>> with x as defined above yields TRUE.
> 
> Christophe Dutang tested this on Mac with the result
>   >  x <- 2^(0:100 + 0)
>   >  all(x == floor(x))
>   [1] TRUE
>   >  all(log2(x) == floor(log2(x)))
>   [1] TRUE
>   > x
>     [1] 1.000000e+00 2.000000e+00 4.000000e+00 8.000000e+00 1.600000e+01
>     [6] 3.200000e+01 6.400000e+01 1.280000e+02 2.560000e+02 5.120000e+02
>    [11] 1.024000e+03 2.048000e+03 4.096000e+03 8.192000e+03 1.638400e+04
>    [16] 3.276800e+04 6.553600e+04 1.310720e+05 2.621440e+05 5.242880e+05
>    [21] 1.048576e+06 2.097152e+06 4.194304e+06 8.388608e+06 1.677722e+07
>    [26] 3.355443e+07 6.710886e+07 1.342177e+08 2.684355e+08 5.368709e+08
>    [31] 1.073742e+09 2.147484e+09 4.294967e+09 8.589935e+09 1.717987e+10
>    ...
> 
> Without an analysis of the error directly on Mac, it is hard to guess,
> what
> is the problem. What could also be tested is, whether the input nruns is
> an
> integer or not. Either strictly, 
>   if (nruns != floor(nruns)) stop("nruns not an integer")
> or with some tolerance
>   nruns0 <- nruns
>   nruns <- round(nruns)
>   if (!isTRUE(all.equal(nruns, nruns0))) stop("nruns not an integer")
> 
> Petr.
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 

Thanks for this test report, sounds as though rounding may not be the issue
here. I've uploaded the version with round instead of floor anyway, together
with a few more bug fixes, and I'll see what happens with the Mac checks on
CRAN. With Mac users being a minority, I'm not willing to complicate things
for other platforms in order to accomodate Mac fixes that I can't even check
myself. But I don't think that this can be all that complicated. If rounding
is not the root cause, someone will certainly come up with another idea.
I'll report back, whether the rounding error approach solved the problem.

Regards, Ulrike 

-- 
View this message in context: http://www.nabble.com/Error-in-FrF2-example-on-Mac-OS-tp22675998p22696051.html
Sent from the R devel mailing list archive at Nabble.com.



More information about the R-devel mailing list