R Under development (unstable) (2023-08-27 r85021 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 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. > library(mbbefd) Loading required package: fitdistrplus Loading required package: MASS Loading required package: survival Loading required package: alabama Loading required package: numDeriv Loading required package: Rcpp Package: mbbefd Version: 0.8.11 Date: BugReport: https://github.com/spedygiorgio/mbbefd/issues > > #test of beta distribution > n <- 1e4 > > x <- roibeta(n, 2, 2, p1=0) > y <- roibeta(n, 4/3, 2/3, p1=0) > > #test CDF > z <- 0:10/10 > cbind(ecdf(x)(z), poibeta(z, 2, 2, 0)) [,1] [,2] [1,] 0.0000 0.000 [2,] 0.0285 0.028 [3,] 0.1068 0.104 [4,] 0.2143 0.216 [5,] 0.3447 0.352 [6,] 0.4994 0.500 [7,] 0.6435 0.648 [8,] 0.7733 0.784 [9,] 0.8940 0.896 [10,] 0.9721 0.972 [11,] 1.0000 1.000 > > cbind(ecdf(y)(z), poibeta(z, 4/3, 2/3, 0)) [,1] [,2] [1,] 0.0000 0.00000000 [2,] 0.0276 0.02936482 [3,] 0.0758 0.07560159 [4,] 0.1365 0.13290373 [5,] 0.2012 0.20018980 [6,] 0.2787 0.27757936 [7,] 0.3616 0.36608701 [8,] 0.4683 0.46791349 [9,] 0.5892 0.58758551 [10,] 0.7376 0.73638534 [11,] 1.0000 1.00000000 > > #total loss > c(etl(x), tloibeta(2, 2, 0)) [1] 0 0 > c(etl(y), tloibeta(4/3, 2/3, 0)) [1] 0 0 > > #mean > c(mean(x), moibeta(1, 2, 2, 0)) [1] 0.5024299 0.5000000 > c(mean(y), moibeta(1, 4/3, 2/3, 0)) [1] 0.6665260 0.6666667 > > > #test EC > cbind(eecf(x)(z), ecoibeta(z, 2, 2, 0)) [,1] [,2] [1,] 0.0000000 0.0000 [2,] 0.1970111 0.1981 [3,] 0.3832494 0.3856 [4,] 0.5507943 0.5541 [5,] 0.6944444 0.6976 [6,] 0.8095194 0.8125 [7,] 0.8951169 0.8976 [8,] 0.9529939 0.9541 [9,] 0.9854947 0.9856 [10,] 0.9980419 0.9981 [11,] 1.0000000 1.0000 > cbind(eecf(y)(z), ecoibeta(z, 4/3, 2/3, 0)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.1481748 0.1481237 [3,] 0.2907638 0.2904043 [4,] 0.4250248 0.4248943 [5,] 0.5498581 0.5500358 [6,] 0.6641792 0.6643336 [7,] 0.7662950 0.7662079 [8,] 0.8545706 0.8538450 [9,] 0.9255516 0.9249505 [10,] 0.9765081 0.9761506 [11,] 1.0000000 1.0000000 > > > > #plots > n <- 1e5 > n <- 1e2 > x <- roibeta(n, 2, 2, p1=0) > y <- roibeta(n, 4/3, 2/3, p1=0) > > > plot(eecf(x), do.points=FALSE) > v <- seq(0, 1, length=101) > lines(v, ecoibeta(v, 2, 2, 0), lty=3, col="red") > > > plot(eecf(y), do.points=FALSE) > v <- seq(0, 1, length=101) > lines(v, ecoibeta(v, 4/3, 2/3, 0), lty=3, col="red") > > > proc.time() user system elapsed 0.98 0.21 1.20