Displaying 20 results from an estimated 10000 matches similar to: "Question about converting from square roots to decimals and back"
2010 Nov 28
5
unexpected behavior using round to 2 digits on randomly generated numbers
Hello!
I stumbled upon something odd that took a while to track down, and I wanted to run it by here to see if I should submit a bug report. For randomly generated numbers (from a variety of distributions) rounding them to specifically 2 digits and then multiplying them by 100 produces strange results on about 8% of cases. The problematic numbers display as I would have expected, but do not
2009 Apr 20
8
bug when subtracting decimals?
Try this:
0.7-0.3==0.4
(We get FALSE)
0.7-0.3<0.4
(We get TRUE)
but
0.8-0.3==0.5
(TRUE)
0.8-0.3<0.5
(FALSE)
Funny, he?
There is a way around:
round(0.7-0.3,1)==0.4
(TRUE)
Obviously there is a problem with some combinations of decimal subtractions,
that - we have the feeling - shouldt be solved.
Best regards
Sven & Wolfgang
--
View this message in context:
2009 Apr 20
8
bug when subtracting decimals?
Try this:
0.7-0.3==0.4
(We get FALSE)
0.7-0.3<0.4
(We get TRUE)
but
0.8-0.3==0.5
(TRUE)
0.8-0.3<0.5
(FALSE)
Funny, he?
There is a way around:
round(0.7-0.3,1)==0.4
(TRUE)
Obviously there is a problem with some combinations of decimal subtractions,
that - we have the feeling - shouldt be solved.
Best regards
Sven & Wolfgang
--
View this message in context:
2008 Nov 07
2
Mismatch in logical result?
Hi R,
I have certain checkings, which gives FALSE, but actually it is true. Why does this happen? Note that the equations that I am checking below are not even the case of recurring decimals...
> 1.4^2 == 1.96
[1] FALSE
> 1.2^3==1.728
[1] FALSE
Thanks in advance, Shubha
Shubha Karanth | Amba Research
Ph +91 80 3980 8031 | Mob +91 94 4886 4510
Bangalore * Colombo *
2008 Nov 03
1
qr() and Gram-Schmidt
Hi,
Why the qr() produces a negative Q compared with Gram-Schmidt? (note
example below, except Q[2,3])
Here is an example, I calculate the Q by Gram-Schmidt process and
compare the output with qr.Q()
a <- c(1,0,1)
b <- c(1,0,0)
c <- c(2,1,0)
x <- matrix(c(a,b,c),3,3)
##########################
# Gram-Schmidt
##########################
A <- matrix(a,3,1)
q1 <-
2003 Apr 22
4
fisher exact vs. simulated chi-square
Dear All,
I have a problem understanding the difference between the outcome of a
fisher exact test and a chi-square test (with simulated p.value).
For some sample data (see below), fisher reports p=.02337. The normal
chi-square test complains about "approximation may be incorrect",
because there is a column with cells with very small values. I
therefore tried the chi-square with
2008 Mar 03
7
help for the first poster- a simple question
Hi, there,
I cannot get accurate value for calculation.
for example:
ld<-sqrt(1*0.05*0.95*0.05*0.95)
0.05*0.95-ld=-6.938894e-18
0.05*0.95-ld==0 is False.
I met this problem in my program, how can I handle it. Thanks.
xj.
2010 Jul 16
3
how to skip a specific value when using apply() function to a matrix?
Hello R experts,
I'd like to studentize a matrix (tmp1) by column using apply() function and skip some specific values such as zeros in the example below to tmp2 but not tmp3. I used the script below and only can get a matrix tmp3. Could you please help me to studentize the matrix (tmp1) without changing the zeros and generate a new matrix tmp2?
Thanks,
Joshua
tmp1
[,1] [,2] [,3] [,4]
2009 Aug 01
5
incorrect result (41/10-1/10)%%1 (PR#13863)
Full_Name: jan hattendorf
Version: 2.9.0
OS: XP
Submission from: (NULL) (213.3.108.185)
I get an incorrect result for
(41/10-1/10)%%1
[1] 1
The error did not occur with other numbers than 41 (1, 11, 21, 31, 51, ...)
test <- rep(NA, 1000)
for(i in 1:1000){
test[i] <- i/10-1/10
}
test[test%%1==0]
2024 Aug 17
2
Strange Behavior in RNG
Hi,
I just observed a strange behavior in R. The rnorm function does not
give me the numbers with a given length. I think it is somehow related
to the internal representation of double-type numbers but I am not
sure if this is supposed to happen. Below is a reproducible example
```
## Create a list, we will only take the forth value, which is 0.6
nList <- seq(0,1,0.2)
n <- nList[4]
n
# [1]
2013 Feb 05
1
How to menage decimals in order to obtain accurate estimates
Hi,
I'm trying to calculate some functions loop, unfortunately my data are
decimal numbers that not allow me to get an accurate estimate. I do not want
to use neither "round "nor "signif" but I would prefer to have all the
information available, (the function loop is generic so you should adapt to
all data, not just those in particular). The approximation error is
2008 Apr 24
2
problem with "which"
Hi,
I'm having trouble with the "which" or the "seq" function, I'm not sure.
Here's an example :
> lat=seq(1,2,by=0.1)
> lat
[1] 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0
> which(lat==1)
[1] 1
> which(lat==1.1)
[1] 2
> which(lat==1.2)
[1] 3
> which(lat==1.3)
[1] 4
> which(lat==1.4)
[1] 5
> which(lat==1.5)
[1] 6
>
2008 Dec 05
3
Logical inconsistency
Dear colleagues
Please could someone kindly explain the following inconsistencies I've discovered when performing logical calculations in R:
8.8 - 7.8 > 1
> TRUE
8.3 - 7.3 > 1
> TRUE
Thank you,
Emma Jane
[[alternative HTML version deleted]]
2017 Jun 07
3
An R question
Hi all,
In checking my R codes, I encountered the following problem. Is there a
way to fix this?
I tried to specify options(digits=). I did not fix the problem.
Thanks so much for your help!
Hanna
> cdf(pmass)[2,2]==pcum[2,2][1] FALSE> cdf(pmass)[2,2][1] 0.9999758> pcum[2,2][1] 0.9999758
[[alternative HTML version deleted]]
2003 Nov 18
1
aov with Error and lme
Hi
I searched in the list and only found questions
without answers e.g.
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/19955.html
: Is there a way to get the same results with lme as
with aov with Error()?
Can anybody reproduce the following results with lme:
id<-c(1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5)
2010 Dec 20
6
sample() issue
> length(sample(25000, 25000*(1-.55)))
[1] 11249
> 25000*(1-.55)
[1] 11250
> length(sample(25000, 11250))
[1] 11250
> length(sample(25000, 25000*.45))
[1] 11250
So the question is, why do I get 11249 out of the first command and not
11250? I can't figure this one out.
Thanks
Cory
[[alternative HTML version deleted]]
2005 May 22
3
comparison operator, decimals, and signif()
Hi, I recently spent quite a bit of time trouble
shooting a function that I had written only to
discover that the problem I was having was with the
comparison operator. I assumed that the following
would return TRUE:
> testMean <- 82.8 + 0.1
> testMean
[1] 82.9
> testMean == 82.9
[1] FALSE
Apparently this has to do with deciml places. Look:
> newTest <- 82.0
> newTest
[1]
2009 Apr 17
3
Modular Arithmetic Error?
Hi,
I'm using the '%%' operator in some code, and am running into the following erroneous outcome:
> 1.2 %% 0.2
[1] 0.2
Unless I'm very mistaken, the result should be 0 (indeed, 12 %% 2 does result in 0). Furthermore:
> 1.20000000000000001 %% 0.2
[1] 0.2
> (1.2+1e17) %% .2
[1] 0
Warning message:
probable complete loss of accuracy in modulus
(Warning
2003 Sep 25
1
apply on a 4D array
I am trying to multiply a 3D array of 4x4x4 by the 4 3D arrays of a 4D array
with dimensions 4x4x4x4 (the last dimension being the one that I want to
split by).
(4x4x4 array)
> hiaAry
, , a1
i1 i2 i3 i4
h1 9.5936098 6.001040 0.08772 0.3138600
h2 1.2003500 1.454570 2.79248 0.0000000
h3 0.1346500 0.201220 0.39256 0.5464000
h4 0.0109000 0.012270 0.16417 0.2766900
,
2011 Apr 13
1
Decimals in R/SQL
Hello,
When I am writing in sqldf or RSQLite I lose the decimals in my matrix.
The only way I can get decimals is by multiplying by 1.00000, etc. I
have tried manipulating the options, but it is only effective once I
multiply by 1.0000.
I appreciate any suggestions!
Thanks!
Example:
z <- sqldf ("select ST,
SUM(AGEP*PWGTP)*1.000000000/SUM(PWGTP)*1.00000000000000 as wgtage from
ss09