Full_Name: Manuel Luethi Version: 2.9.1 OS: Windows XP Submission from: (NULL) (129.132.128.136) Hi I created the following vectors: p_1=c(0.2,0.2,0.2,0.2,0.1,0.25,0.4,0.1,0.25,0.4,0.1,0.25,0.4,0.1,0.25,0.4,0.2,0.5,0.8,0.2,0.5,0.8,0.2,0.5,0.8,0.2,0.5,0.8) p_2=c(0,0,0,0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.4,0.25,0.1,0.4,0.25,0.1,0.4,0.25,0.1,0.4,0.25,0.1) As these are probabilities, I calculated the remainder as p_3=1-p_1-p_2 There the values which ought to be 0.1 were lateron not recognised by p_3==0.1, but only if I used p_3 <= 0.1. The full calculation is actually bigger but the core issue remains: I used values input by hand, built a difference and it was wrong. I know that exactly the value 0.1 is one that can not be represented using binary rep. Maybe that's it, maybe not. Just wanted to let you know. With kind regards Manuel
On Tue, Aug 04, 2009 at 04:25:09PM +0200, luethman at student.ethz.ch wrote:> Hi > > I created the following vectors: > > p_1=c(0.2,0.2,0.2,0.2,0.1,0.25,0.4,0.1,0.25,0.4,0.1,0.25,0.4,0.1,0.25,0.4,0.2,0.5,0.8,0.2,0.5,0.8,0.2,0.5,0.8,0.2,0.5,0.8) > p_2=c(0,0,0,0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.4,0.25,0.1,0.4,0.25,0.1,0.4,0.25,0.1,0.4,0.25,0.1) > > As these are probabilities, I calculated the remainder as > > p_3=1-p_1-p_2 > > There the values which ought to be 0.1 were lateron not recognised by p_3==0.1, > but only if I used p_3 <= 0.1. > > The full calculation is actually bigger but the core issue remains: I used > values input by hand, built a difference and it was wrong. > > I know that exactly the value 0.1 is one that can not be represented using > binary rep. Maybe that's it, maybe not.Yes, this is the problem. In this case, one can obtain a correct result using round() p1 <- c(0.2,0.2,0.2,0.2,0.1,0.25,0.4,0.1,0.25,0.4,0.1,0.25,0.4,0.1, 0.25,0.4,0.2,0.5,0.8,0.2,0.5,0.8,0.2,0.5,0.8,0.2,0.5,0.8) p2 <- c(0,0,0,0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.4, 0.25,0.1,0.4,0.25,0.1,0.4,0.25,0.1,0.4,0.25,0.1) p3 <- 1 - p1 - p2 round(p3, 2) == 0.1 # [1] FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE TRUE FALSE FALSE # [13] TRUE FALSE FALSE TRUE FALSE FALSE TRUE FALSE FALSE TRUE FALSE FALSE # [25] TRUE FALSE FALSE TRUE Petr.
What research into this problem did you do that failed to turn up FAQ 7.31? -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-devel-bounces at r-project.org [mailto:r-devel-bounces at r- > project.org] On Behalf Of luethman at student.ethz.ch > Sent: Tuesday, August 04, 2009 8:25 AM > To: r-devel at stat.math.ethz.ch > Cc: R-bugs at r-project.org > Subject: [Rd] Accuracy (PR#13867) > > Full_Name: Manuel Luethi > Version: 2.9.1 > OS: Windows XP > Submission from: (NULL) (129.132.128.136) > > > Hi > > I created the following vectors: > > p_1=c(0.2,0.2,0.2,0.2,0.1,0.25,0.4,0.1,0.25,0.4,0.1,0.25,0.4,0.1,0.25,0 > .4,0.2,0.5,0.8,0.2,0.5,0.8,0.2,0.5,0.8,0.2,0.5,0.8) > p_2=c(0,0,0,0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.4,0.25, > 0.1,0.4,0.25,0.1,0.4,0.25,0.1,0.4,0.25,0.1) > > As these are probabilities, I calculated the remainder as > > p_3=1-p_1-p_2 > > There the values which ought to be 0.1 were lateron not recognised by > p_3==0.1, > but only if I used p_3 <= 0.1. > > The full calculation is actually bigger but the core issue remains: I > used > values input by hand, built a difference and it was wrong. > > I know that exactly the value 0.1 is one that can not be represented > using > binary rep. Maybe that's it, maybe not. Just wanted to let you know. > > With kind regards > > Manuel > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
What research into this problem did you do that failed to turn up FAQ 7.31? --=20 Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-devel-bounces at r-project.org [mailto:r-devel-bounces at r- > project.org] On Behalf Of luethman at student.ethz.ch > Sent: Tuesday, August 04, 2009 8:25 AM > To: r-devel at stat.math.ethz.ch > Cc: R-bugs at r-project.org > Subject: [Rd] Accuracy (PR#13867) >=20 > Full_Name: Manuel Luethi > Version: 2.9.1 > OS: Windows XP > Submission from: (NULL) (129.132.128.136) >=20 >=20 > Hi >=20 > I created the following vectors: >=20 > p_1=3Dc(0.2,0.2,0.2,0.2,0.1,0.25,0.4,0.1,0.25,0.4,0.1,0.25,0.4,0.1,0.25,0 > .4,0.2,0.5,0.8,0.2,0.5,0.8,0.2,0.5,0.8,0.2,0.5,0.8) > p_2=3Dc(0,0,0,0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.4,0.25, > 0.1,0.4,0.25,0.1,0.4,0.25,0.1,0.4,0.25,0.1) >=20 > As these are probabilities, I calculated the remainder as >=20 > p_3=3D1-p_1-p_2 >=20 > There the values which ought to be 0.1 were lateron not recognised by > p_3=3D=3D0.1, > but only if I used p_3 <=3D 0.1. >=20 > The full calculation is actually bigger but the core issue remains: I > used > values input by hand, built a difference and it was wrong. >=20 > I know that exactly the value 0.1 is one that can not be represented > using > binary rep. Maybe that's it, maybe not. Just wanted to let you know. >=20 > With kind regards >=20 > Manuel >=20 > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
Possibly Parallel Threads
- Polynomial regression help
- [LLVMdev] [Polly] Analysis of the expensive compile-time overhead of Polly Dependence pass
- [LLVMdev] [Polly] Analysis of the expensive compile-time overhead of Polly Dependence pass
- how to speed up the inefficient code
- Non-R question.