R Under development (unstable) (2024-12-17 r87446 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. > 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.13 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.0320 0.028 [3,] 0.1095 0.104 [4,] 0.2192 0.216 [5,] 0.3567 0.352 [6,] 0.5036 0.500 [7,] 0.6481 0.648 [8,] 0.7798 0.784 [9,] 0.8884 0.896 [10,] 0.9704 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.0287 0.02936482 [3,] 0.0748 0.07560159 [4,] 0.1320 0.13290373 [5,] 0.1990 0.20018980 [6,] 0.2735 0.27757936 [7,] 0.3622 0.36608701 [8,] 0.4644 0.46791349 [9,] 0.5834 0.58758551 [10,] 0.7333 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.4989443 0.5000000 > c(mean(y), moibeta(1, 4/3, 2/3, 0)) [1] 0.6692208 0.6666667 > > > #test EC > cbind(eecf(x)(z), ecoibeta(z, 2, 2, 0)) [,1] [,2] [1,] 0.0000000 0.0000 [2,] 0.1981980 0.1981 [3,] 0.3851798 0.3856 [4,] 0.5529354 0.5541 [5,] 0.6956240 0.6976 [6,] 0.8099247 0.8125 [7,] 0.8949313 0.8976 [8,] 0.9519045 0.9541 [9,] 0.9844063 0.9856 [10,] 0.9978621 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.1475449 0.1481237 [3,] 0.2892875 0.2904043 [4,] 0.4234449 0.4248943 [5,] 0.5481443 0.5500358 [6,] 0.6625154 0.6643336 [7,] 0.7647885 0.7662079 [8,] 0.8526385 0.8538450 [9,] 0.9241568 0.9249505 [10,] 0.9756758 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 1.70 0.29 1.98