Closed vaclavcepelak closed 3 years ago
Here is my sessionInfo if relevant:
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=Czech_Czechia.1250 LC_CTYPE=Czech_Czechia.1250 LC_MONETARY=Czech_Czechia.1250
[4] LC_NUMERIC=C LC_TIME=Czech_Czechia.1250
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] eventdetection_0.0.0.9000 data.table_1.10.4-3
loaded via a namespace (and not attached):
[1] httr_1.3.1 tidyr_0.7.2 jsonlite_1.5 modelr_0.1.1 assertthat_0.2.0
[6] TTR_0.23-2 cellranger_1.1.0 backports_1.1.1 lattice_0.20-35 glue_1.2.0
[11] digest_0.6.12 rvest_0.3.2 colorspace_1.3-2 plyr_1.8.4 psych_1.7.8
[16] pkgconfig_2.0.1 devtools_1.13.4 broom_0.4.3 haven_1.1.0 purrr_0.2.4
[21] scales_0.5.0 tibble_1.3.4 ggplot2_2.2.1 withr_2.1.0 tidyverse_1.2.1
[26] lazyeval_0.2.1 mnormt_1.5-5 magrittr_1.5 crayon_1.3.4 readxl_1.0.0
[31] memoise_1.1.0 nlme_3.1-131 forcats_0.2.0 xts_0.10-0 xml2_1.1.1
[36] foreign_0.8-69 tools_3.4.3 hms_0.4.0 stringr_1.2.0 munsell_0.4.3
[41] lambda.r_1.2 bindrcpp_0.2 compiler_3.4.3 rlang_0.1.4 futile.logger_1.4.3
[46] grid_3.4.3 rstudioapi_0.7 testthat_2.0.0 gtable_0.2.0 roxygen2_6.0.1
[51] curl_3.0 reshape2_1.4.2 R6_2.2.2 zoo_1.8-0 lubridate_1.7.1
[56] dplyr_0.7.4 bindr_0.1 commonmark_1.4 rprojroot_1.2 futile.options_1.0.0
[61] readr_1.1.1 desc_1.1.1 stringi_1.1.6 parallel_3.4.3 Rcpp_0.12.14
That's a consequence of floating point arithmetic. David Goldberg provides a great overview in What Every Computer Scientist Should Know About Floating-Point Arithmetic.
I agree it would be nice to less rounding error, but there's a trade-off between speed and accuracy. It would also be non-trivial to implement a patch for greater accuracy. You should compare the absolute value of the difference of two numbers if you want to know whether they're significantly different from each other.
Many thanks for an explanation.
Closing this, since I am very unlikely to implement a change to address this behavior.
Dear Joshua,
the following code
TTR::runSD(rep(0.001,12))
should in my opinion return vector of 9 NAs and 3 zeros but returns
[1] NA NA NA NA NA NA NA NA NA [10] 0.000000e+00 2.285699e-19 2.285699e-19
I haven't found this issue reported earlier. Thank you very much for looking at it!
Vaclav