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 shifted truncated pareto distribution > n <- 1e4 > > x <- roistpareto(n, 2, p1=1/2) > y <- roistpareto(n, 1/2, p1=1/3) > > #test CDF > z <- 0:10/10 > cbind(ecdf(x)(z), poistpareto(z, 2, 1/2)) [,1] [,2] [1,] 0.0000 0.0000000 [2,] 0.1168 0.1157025 [3,] 0.2030 0.2037037 [4,] 0.2707 0.2721893 [5,] 0.3223 0.3265306 [6,] 0.3658 0.3703704 [7,] 0.4036 0.4062500 [8,] 0.4338 0.4359862 [9,] 0.4600 0.4609053 [10,] 0.4799 0.4819945 [11,] 1.0000 1.0000000 > > cbind(ecdf(y)(z), poistpareto(z, 1/2, 1/3)) [,1] [,2] [1,] 0.0000 0.0000000 [2,] 0.1087 0.1059258 [3,] 0.2010 0.1983182 [4,] 0.2806 0.2798335 [5,] 0.3522 0.3524510 [6,] 0.4182 0.4176799 [7,] 0.4752 0.4766938 [8,] 0.5302 0.5304209 [9,] 0.5807 0.5796060 [10,] 0.6227 0.6248551 [11,] 1.0000 1.0000000 > > #total loss > c(etl(x), tloistpareto(2, 1/2)) [1] 0.5012 0.5000 > c(etl(y), tloistpareto(1/2, 1/3)) [1] 0.3318000 0.3333333 > > #mean > c(mean(x), moistpareto(1, 2, 1/2)) [1] 0.6688250 0.6666667 > c(mean(y), moistpareto(1, 1/2, 1/3)) [1] 0.6088921 0.6094757 > > > #test EC > cbind(eecf(x)(z), ecoistpareto(z, 2, 1/2)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.1403896 0.1409091 [3,] 0.2656681 0.2666667 [4,] 0.3796460 0.3807692 [5,] 0.4846971 0.4857143 [6,] 0.5829973 0.5833333 [7,] 0.6750210 0.6750000 [8,] 0.7618921 0.7617647 [9,] 0.8444469 0.8444444 [10,] 0.9236213 0.9236842 [11,] 1.0000000 1.0000000 > cbind(eecf(y)(z), ecoistpareto(z, 1/2, 1/3)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.1550144 0.1551785 [3,] 0.2937500 0.2941296 [4,] 0.4182081 0.4188448 [5,] 0.5303443 0.5309387 [6,] 0.6312778 0.6317421 [7,] 0.7219816 0.7223671 [8,] 0.8035096 0.8037543 [9,] 0.8765038 0.8767080 [10,] 0.9420167 0.9419220 [11,] 1.0000000 1.0000000 > > > > #plots > n <- 1e2 > x <- roistpareto(n, 2, p1=1/2) > y <- roistpareto(n, 1/2, p1=1/3) > > > plot(eecf(x), do.points=FALSE) > v <- seq(0, 1, length=101) > lines(v, ecoistpareto(v, 2, 1/2), lty=3, col="red") > > > plot(eecf(y), do.points=FALSE) > v <- seq(0, 1, length=101) > lines(v, ecoistpareto(v, 1/2, 1/3), lty=3, col="red") > > > proc.time() user system elapsed 1.68 0.31 2.01