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 uniform distribution > n <- 1e4 > > x <- roiunif(n, p1=1/2) > y <- roiunif(n, p1=1/3) > > #test CDF > z <- 0:10/10 > cbind(ecdf(x)(z), poiunif(z, 1/2)) [,1] [,2] [1,] 0.0000 0.00 [2,] 0.0461 0.05 [3,] 0.0968 0.10 [4,] 0.1444 0.15 [5,] 0.1939 0.20 [6,] 0.2439 0.25 [7,] 0.2921 0.30 [8,] 0.3398 0.35 [9,] 0.3904 0.40 [10,] 0.4402 0.45 [11,] 1.0000 1.00 > > cbind(ecdf(y)(z), poiunif(z, 1/3)) [,1] [,2] [1,] 0.0000 0.00000000 [2,] 0.0656 0.06666667 [3,] 0.1347 0.13333333 [4,] 0.1993 0.20000000 [5,] 0.2680 0.26666667 [6,] 0.3355 0.33333333 [7,] 0.4012 0.40000000 [8,] 0.4726 0.46666667 [9,] 0.5404 0.53333333 [10,] 0.6010 0.60000000 [11,] 1.0000 1.00000000 > > #total loss > c(etl(x), tloiunif(1/2)) [1] 0.509 0.500 > c(etl(y), tloiunif(1/3)) [1] 0.3319000 0.3333333 > > #mean > c(mean(x), moiunif(1, 1/2)) [1] 0.7569895 0.7500000 > c(mean(y), moiunif(1, 1/3)) [1] 0.6649892 0.6666667 > > > #test EC > cbind(eecf(x)(z), ecoiunif(z, 1/2)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.1289923 0.1300000 [3,] 0.2518184 0.2533333 [4,] 0.3680767 0.3700000 [5,] 0.4779076 0.4800000 [6,] 0.5809572 0.5833333 [7,] 0.6775497 0.6800000 [8,] 0.7678542 0.7700000 [9,] 0.8519760 0.8533333 [10,] 0.9293032 0.9300000 [11,] 1.0000000 1.0000000 > cbind(eecf(y)(z), ecoiunif(z, 1/3)) [,1] [,2] [1,] 0.0000000 0.000 [2,] 0.1455286 0.145 [3,] 0.2808569 0.280 [4,] 0.4061411 0.405 [5,] 0.5212505 0.520 [6,] 0.6263604 0.625 [7,] 0.7213805 0.720 [8,] 0.8061152 0.805 [9,] 0.8803741 0.880 [10,] 0.9449415 0.945 [11,] 1.0000000 1.000 > > > > #plots > n <- 1e2 > x <- roiunif(n, p1=1/2) > y <- roiunif(n, p1=1/3) > > > plot(eecf(x), do.points=FALSE) > v <- seq(0, 1, length=101) > lines(v, ecoiunif(v, 1/2), lty=3, col="red") > > > plot(eecf(y), do.points=FALSE) > v <- seq(0, 1, length=101) > lines(v, ecoiunif(v, 1/3), lty=3, col="red") > > > proc.time() user system elapsed 1.1 0.1 1.2