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 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.1154 0.1157025 [3,] 0.2094 0.2037037 [4,] 0.2805 0.2721893 [5,] 0.3354 0.3265306 [6,] 0.3773 0.3703704 [7,] 0.4126 0.4062500 [8,] 0.4431 0.4359862 [9,] 0.4687 0.4609053 [10,] 0.4923 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.1040 0.1059258 [3,] 0.1915 0.1983182 [4,] 0.2750 0.2798335 [5,] 0.3524 0.3524510 [6,] 0.4170 0.4176799 [7,] 0.4745 0.4766938 [8,] 0.5277 0.5304209 [9,] 0.5777 0.5796060 [10,] 0.6225 0.6248551 [11,] 1.0000 1.0000000 > > #total loss > c(etl(x), tloistpareto(2, 1/2)) [1] 0.4897 0.5000 > c(etl(y), tloistpareto(1/2, 1/3)) [1] 0.3380000 0.3333333 > > #mean > c(mean(x), moistpareto(1, 2, 1/2)) [1] 0.6606136 0.6666667 > c(mean(y), moistpareto(1, 1/2, 1/3)) [1] 0.6122569 0.6094757 > > > #test EC > cbind(eecf(x)(z), ecoistpareto(z, 2, 1/2)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.1426490 0.1409091 [3,] 0.2693597 0.2666667 [4,] 0.3834250 0.3807692 [5,] 0.4880136 0.4857143 [6,] 0.5853100 0.5833333 [7,] 0.6769010 0.6750000 [8,] 0.7634481 0.7617647 [9,] 0.8458767 0.8444444 [10,] 0.9244824 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.1545641 0.1551785 [3,] 0.2935725 0.2941296 [4,] 0.4187610 0.4188448 [5,] 0.5308286 0.5309387 [6,] 0.6313533 0.6317421 [7,] 0.7216307 0.7223671 [8,] 0.8031271 0.8037543 [9,] 0.8762595 0.8767080 [10,] 0.9416341 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.06 0.14 1.20