R Under development (unstable) (2024-10-16 r87241 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.12 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.0487 0.05 [3,] 0.0962 0.10 [4,] 0.1470 0.15 [5,] 0.1964 0.20 [6,] 0.2462 0.25 [7,] 0.2960 0.30 [8,] 0.3491 0.35 [9,] 0.4003 0.40 [10,] 0.4487 0.45 [11,] 1.0000 1.00 > > cbind(ecdf(y)(z), poiunif(z, 1/3)) [,1] [,2] [1,] 0.0000 0.00000000 [2,] 0.0691 0.06666667 [3,] 0.1347 0.13333333 [4,] 0.2029 0.20000000 [5,] 0.2710 0.26666667 [6,] 0.3384 0.33333333 [7,] 0.4071 0.40000000 [8,] 0.4721 0.46666667 [9,] 0.5347 0.53333333 [10,] 0.6000 0.60000000 [11,] 1.0000 1.00000000 > > #total loss > c(etl(x), tloiunif(1/2)) [1] 0.4989 0.5000 > c(etl(y), tloiunif(1/3)) [1] 0.3340000 0.3333333 > > #mean > c(mean(x), moiunif(1, 1/2)) [1] 0.7518445 0.7500000 > c(mean(y), moiunif(1, 1/3)) [1] 0.6629736 0.6666667 > > > #test EC > cbind(eecf(x)(z), ecoiunif(z, 1/2)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.1297395 0.1300000 [3,] 0.2530001 0.2533333 [4,] 0.3698812 0.3700000 [5,] 0.4801499 0.4800000 [6,] 0.5835903 0.5833333 [7,] 0.6803856 0.6800000 [8,] 0.7703460 0.7700000 [9,] 0.8535930 0.8533333 [10,] 0.9301443 0.9300000 [11,] 1.0000000 1.0000000 > cbind(eecf(y)(z), ecoiunif(z, 1/3)) [,1] [,2] [1,] 0.0000000 0.000 [2,] 0.1455858 0.145 [3,] 0.2810443 0.280 [4,] 0.4060692 0.405 [5,] 0.5210258 0.520 [6,] 0.6257380 0.625 [7,] 0.7201718 0.720 [8,] 0.8044705 0.805 [9,] 0.8794584 0.880 [10,] 0.9447226 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.17 0.21 1.37