R Under development (unstable) (2024-08-17 r87027 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > require(Rmpfr) Loading required package: Rmpfr Loading required package: gmp Attaching package: 'gmp' The following objects are masked from 'package:base': %*%, apply, crossprod, matrix, tcrossprod C code of R package 'Rmpfr': GMP using 64 bits per limb Attaching package: 'Rmpfr' The following object is masked from 'package:gmp': outer The following objects are masked from 'package:stats': dbinom, dgamma, dnbinom, dnorm, dpois, dt, pnorm The following objects are masked from 'package:base': cbind, pmax, pmin, rbind > require(DPQmpfr) Loading required package: DPQmpfr > > stopifnot(all.equal(DPQ:::dntJKBf(mpfr(0, 64), 5,10), ## gave NaN + 3.66083172640611114864e-23, tol=1e-20)) > ## whereas R's 2018-08 > dt(0, 5, 10) # is a factor of 2 too large: 7.321663e-23 [1] 7.321663e-23 > > (dt5.10m <- dntJKBm(mpfr(-4:4, 256), 5, 10))##--> heureka! 9 'mpfr' numbers of precision 256 bits [1] 2.60411193283363008816174203664672521049598232817191096334231768533123433930554e-29 [2] 1.402390045022762576904908969928231134641459245433370510245082462639551869912683e-28 [3] 1.423497061270720045959087598996775429320328607547260643299749804014121024358857e-27 [4] 5.449436753201393001156967930749166463526468918232281745544244816776279420757684e-26 [5] 3.660831726406111150918497564522165417454008321092157460964035675595080684479716e-23 [6] 1.035962495942093066639658406747234090777907965780567084318709388913711965340062e-16 [7] 2.85854048117620027304802327696150987469187879228812294414362851419136085231108e-10 [8] 3.65628559654324497017621253550780270928261249913747846398933155144922638545515e-6 [9] 0.0006233252495097859026032404406354378980224459220868988071467401913727754970112061 Warning message: In dntJKBm(mpfr(-4:4, 256), 5, 10) : 'dntJKBm' is deprecated. Use 'DPQ::dntJKBf' instead. See help("Deprecated") > > stopifnot(all.equal(dt5.10m, tolerance = 1e-7 , + c(2.604112e-29, 1.40239e-28, 1.423497e-27, 5.449437e-26, + 3.660832e-23, + 1.035962e-16, 2.85854e-10, 3.656286e-06, 0.0006233252))) > > cbind(x = -4:4, + dt.log = dt(-4:4, 5, 10, log=TRUE), # x <= 0: not good! + log.dt.M = asNumeric(log(dt5.10m))) x dt.log log.dt.M [1,] -4 -32.265162 -65.817876 [2,] -3 -31.641007 -64.134205 [3,] -2 -32.209592 -61.816681 [4,] -1 -Inf -58.171700 [5,] 0 -50.968620 -51.661767 [6,] 1 -36.810333 -36.806031 [7,] 2 -21.975748 -21.975540 [8,] 3 -12.519063 -12.519063 [9,] 4 -7.380442 -7.380442 > > ## FIXME: ==> more in ~/R/MM/NUMERICS/dpq-functions/dt-ex.R > > > > proc.time() user system elapsed 1.84 0.14 1.96