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 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.1206 0.1157025 [3,] 0.2112 0.2037037 [4,] 0.2795 0.2721893 [5,] 0.3320 0.3265306 [6,] 0.3760 0.3703704 [7,] 0.4138 0.4062500 [8,] 0.4444 0.4359862 [9,] 0.4702 0.4609053 [10,] 0.4903 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.1048 0.1059258 [3,] 0.1976 0.1983182 [4,] 0.2826 0.2798335 [5,] 0.3588 0.3524510 [6,] 0.4280 0.4176799 [7,] 0.4867 0.4766938 [8,] 0.5386 0.5304209 [9,] 0.5842 0.5796060 [10,] 0.6284 0.6248551 [11,] 1.0000 1.0000000 > > #total loss > c(etl(x), tloistpareto(2, 1/2)) [1] 0.4923 0.5000 > c(etl(y), tloistpareto(1/2, 1/3)) [1] 0.3309000 0.3333333 > > #mean > c(mean(x), moistpareto(1, 2, 1/2)) [1] 0.6596253 0.6666667 > c(mean(y), moistpareto(1, 1/2, 1/3)) [1] 0.6050400 0.6094757 > > > #test EC > cbind(eecf(x)(z), ecoistpareto(z, 2, 1/2)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.1420050 0.1409091 [3,] 0.2679830 0.2666667 [4,] 0.3824078 0.3807692 [5,] 0.4874186 0.4857143 [6,] 0.5851883 0.5833333 [7,] 0.6769014 0.6750000 [8,] 0.7633788 0.7617647 [9,] 0.8454642 0.8444444 [10,] 0.9241937 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.1562308 0.1551785 [3,] 0.2963843 0.2941296 [4,] 0.4217583 0.4188448 [5,] 0.5339874 0.5309387 [6,] 0.6341170 0.6317421 [7,] 0.7236369 0.7223671 [8,] 0.8042331 0.8037543 [9,] 0.8767673 0.8767080 [10,] 0.9419778 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.31 0.12 1.43