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 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.0495 0.05 [3,] 0.0970 0.10 [4,] 0.1491 0.15 [5,] 0.1987 0.20 [6,] 0.2487 0.25 [7,] 0.3016 0.30 [8,] 0.3495 0.35 [9,] 0.3983 0.40 [10,] 0.4494 0.45 [11,] 1.0000 1.00 > > cbind(ecdf(y)(z), poiunif(z, 1/3)) [,1] [,2] [1,] 0.0000 0.00000000 [2,] 0.0649 0.06666667 [3,] 0.1320 0.13333333 [4,] 0.1980 0.20000000 [5,] 0.2651 0.26666667 [6,] 0.3324 0.33333333 [7,] 0.4030 0.40000000 [8,] 0.4720 0.46666667 [9,] 0.5392 0.53333333 [10,] 0.6040 0.60000000 [11,] 1.0000 1.00000000 > > #total loss > c(etl(x), tloiunif(1/2)) [1] 0.4974 0.5000 > c(etl(y), tloiunif(1/3)) [1] 0.3314000 0.3333333 > > #mean > c(mean(x), moiunif(1, 1/2)) [1] 0.7508386 0.7500000 > c(mean(y), moiunif(1, 1/3)) [1] 0.6656494 0.6666667 > > > #test EC > cbind(eecf(x)(z), ecoiunif(z, 1/2)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.1299011 0.1300000 [3,] 0.2532502 0.2533333 [4,] 0.3701418 0.3700000 [5,] 0.4800766 0.4800000 [6,] 0.5833397 0.5833333 [7,] 0.6799133 0.6800000 [8,] 0.7698516 0.7700000 [9,] 0.8533007 0.8533333 [10,] 0.9301331 0.9300000 [11,] 1.0000000 1.0000000 > cbind(eecf(y)(z), ecoiunif(z, 1/3)) [,1] [,2] [1,] 0.0000000 0.000 [2,] 0.1455850 0.145 [3,] 0.2809560 0.280 [4,] 0.4064455 0.405 [5,] 0.5217656 0.520 [6,] 0.6270613 0.625 [7,] 0.7219900 0.720 [8,] 0.8065832 0.805 [9,] 0.8810051 0.880 [10,] 0.9452918 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.67 0.32 1.98