由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - a R question
相关主题
请教个R的问题R里为什么3.1+2.7==5.8是false?
round问题An error message in R
sas coding help needed问个R的小题目
请教一个R的问题,谢谢!请教一个R的问题,quantcut
"&" vs "&&" in RR Matrix 初级问题
R:matrixRandom forests on imbalanced data (转载)
有 SAS 或者 R 或者其他program的 code 能 查 fake email的不?measuring the change of intercept
如何计算BETWEEN AND WITHIN VARIANCE(包子求帮助)这个应该用什么correlation?
相关话题的讨论汇总
话题: false话题: true话题: 24话题: question话题: hi
进入Statistics版参与讨论
1 (共1页)
i*****y
发帖数: 188
1
Hi,
I was wondering if someone could help me with the following problem I
encountered...
> a<-502.167
> b<-526.167
> c=478.167
> b-a==24
[1] FALSE
> a-c==24
[1] TRUE
I do not understand why I got "FALSE" for b-a==24 while "TRUE" for a-c==24?
Thanks a lot.
k*******a
发帖数: 772
2
这个好像没啥好办法, 见R-FAQ
7.31 Why doesn't R think these numbers are equal?
The only numbers that can be represented exactly in R's numeric type are
integers and fractions whose denominator is a power of 2. Other numbers have
to be rounded to (typically) 53 binary digits accuracy. As a result, two
floating point numbers will not reliably be equal unless they have been
computed by the same algorithm, and not always even then. For example
R> a <- sqrt(2)
R> a * a == 2
[1] FALSE
R> a * a - 2
[1] 4.440892e-16
The function all.equal() compares two objects using a numeric tolerance of .
Machine$double.eps ^ 0.5. If you want much greater accuracy than this you
will need to consider error propagation carefully.
i*****y
发帖数: 188
3
Hi,
Thank you so much. It is really helpful.
e****z
发帖数: 119
4
I guess it is because R uses a different data type (maybe long int) to store
a value above a cutoff. Based on your example, the cutoff is mostly likely
to be 512.
c*****m
发帖数: 4817
5
浮点数精度问题,任何语言都有

【在 i*****y 的大作中提到】
: Hi,
: Thank you so much. It is really helpful.

1 (共1页)
进入Statistics版参与讨论
相关主题
这个应该用什么correlation?"&" vs "&&" in R
R这是逗我玩R:matrix
问一个统计弱问题有 SAS 或者 R 或者其他program的 code 能 查 fake email的不?
请教一个正态分布的积分问题如何计算BETWEEN AND WITHIN VARIANCE(包子求帮助)
请教个R的问题R里为什么3.1+2.7==5.8是false?
round问题An error message in R
sas coding help needed问个R的小题目
请教一个R的问题,谢谢!请教一个R的问题,quantcut
相关话题的讨论汇总
话题: false话题: true话题: 24话题: question话题: hi