[R] Variance for Vector of Constants is STILL Not Zero
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sat Feb 18 17:54:33 CET 2006
Note though that this is already giving 0 in both cases in R-devel on
Windows (the only platform on which this difference occurs).
On Sat, 18 Feb 2006, Spencer Graves wrote:
> I got the same thing as Duncan:
>
> > var(rep(0.2, 100))
> [1] 0
> > RSiteSearch('fpu')
> A search query has been submitted to http://search.r-project.org
> The results page should open in your browser shortly
> > var(rep(0.2, 100))
> [1] 1.525181e-31
> > sessionInfo()
> R version 2.2.1, 2005-12-20, i386-pc-mingw32
>
> attached base packages:
> [1] "methods" "stats" "graphics" "grDevices" "utils" "datasets"
> [7] "base"
>
> spencer graves
>
> Duncan Murdoch wrote:
>
>> On 2/17/2006 1:17 PM, Barry Zajdlik wrote:
>>
>>> Hello all,
>>>
>>> Thanks for the responses but I am still annoyed by this seemingly simple
>>> problem; I recorded sessionInfo() as below.
>>>
>>> x<-rep(0.02,10)
>>>
>>>> var(x)
>>>
>>> [1] 1.337451e-35
>>>
>>>> sessionInfo()
>>>
>>> R version 2.1.0, 2005-04-18, i386-pc-mingw32
>>>
>>> attached base packages:
>>> [1] "methods" "stats" "graphics" "grDevices" "utils"
>>> "datasets"
>>> [7] "base"
>>>
>>>
>>> I then decided to download the latest version today but obtained the
>>> same result.
>>>
>>>
>>>> x<-rep(0.02,10)
>>>> var(x)
>>>
>>> [1] 1.337451e-35
>>
>>
>> My guess is that you've got a video driver or some other software that's
>> messing with your floating point processor, reducing the precision from
>> 64 bit to 53 or less. I can reproduce the error after running
>> RSiteSearch, which messes with my fpu in that way:
>>
>> > var(rep(0.2, 100))
>> [1] 0
>> > RSiteSearch('fpu')
>> A search query has been submitted to http://search.r-project.org
>> The results page should open in your browser shortly
>> > var(rep(0.2, 100))
>> [1] 1.525181e-31
>>
>> (I'm not blaming RSiteSearch for doing something bad, it's the system
>> DLLs that it calls that are at fault.)
>>
>> I think this is something we should address, but it's not easy.
>>
>> Duncan Murdoch
>>
>>
>>>> sessionInfo()
>>>
>>> R version 2.2.1, 2005-12-20, i386-pc-mingw32
>>>
>>> attached base packages:
>>> [1] "methods" "stats" "graphics" "grDevices" "utils"
>>> "datasets"
>>> [7] "base"
>>>
>>>
>>> I Changed .Machine$double.eps to make the calculations LESS accurate.
>>> My thought was that if I reduced the precision, 1-eps would return 1
>>> instead of some number less than 1. My thought was that if eps were
>>> sufficiently large my sample problem would return a zero. This didn't
>>> happen though.
>>>
>>> Again, any thoughts would be appreciated.
>>>
>>> Regards,
>>> Barry Zajdlik
>>>
>>> ______________________________________________
>>> R-help at stat.math.ethz.ch mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
--
Brian D. Ripley, ripley at 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 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list