R Under development (unstable) (2024-07-10 r86888 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(fitdistrplus) Loading required package: MASS Loading required package: survival > set.seed(1234) > nsample <- 10 > > #Poisson > > x <- rpois(nsample, lambda=7.5) > L2 <- function(lam) + (qpois(1/2, lambda = lam) - median(x))^2 > curve(L2(x), 5, 9, xlab=expression(lambda), ylab=expression(L2(lambda)), main="squared differences", n=201) > > fitdist(x, "pois", method="qme", probs=1/2, start=list(lambda=2), control=list(trace=1, REPORT=1)) initial value 36.000000 iter 1 value 36.000000 final value 36.000000 converged Fitting of the distribution ' pois ' by matching quantiles Parameters: estimate lambda 2 > fitdist(x, "pois", method="qme", probs=1/2, start=list(lambda=6.8), control=list(trace=1, REPORT=1)) initial value 1.000000 iter 1 value 1.000000 final value 1.000000 converged Fitting of the distribution ' pois ' by matching quantiles Parameters: estimate lambda 6.8 > fitdist(x, "pois", method="qme", probs=1/2, start=list(lambda=15), control=list(trace=1, REPORT=1)) initial value 49.000000 iter 1 value 49.000000 final value 49.000000 converged Fitting of the distribution ' pois ' by matching quantiles Parameters: estimate lambda 15 > > fitdist(x, "pois", method="qme", optim.method="SANN", probs=1/2, start=list(lambda=2), control=list(trace=1, REPORT=100)) sann objective function values initial value 36.000000 iter 1000 value 0.000000 iter 2000 value 0.000000 iter 3000 value 0.000000 iter 4000 value 0.000000 iter 5000 value 0.000000 iter 6000 value 0.000000 iter 7000 value 0.000000 iter 8000 value 0.000000 iter 9000 value 0.000000 iter 9999 value 0.000000 final value 0.000000 sann stopped after 9999 iterations Fitting of the distribution ' pois ' by matching quantiles Parameters: estimate lambda 8.425269 > fitdist(x, "pois", method="qme", optim.method="SANN", probs=1/2, start=list(lambda=17), control=list(trace=1, REPORT=100)) sann objective function values initial value 81.000000 iter 1000 value 0.000000 iter 2000 value 0.000000 iter 3000 value 0.000000 iter 4000 value 0.000000 iter 5000 value 0.000000 iter 6000 value 0.000000 iter 7000 value 0.000000 iter 8000 value 0.000000 iter 9000 value 0.000000 iter 9999 value 0.000000 final value 0.000000 sann stopped after 9999 iterations Fitting of the distribution ' pois ' by matching quantiles Parameters: estimate lambda 8.183321 > > > > #Geometric > > x <- rgeom(nsample, 1/3) > L2 <- function(p) + (qgeom(1/2, p) - median(x))^2 > curve(L2(x), 0.10, 0.95, xlab=expression(p), ylab=expression(L2(p)), main="squared differences", n=301) > > fitdist(x, "geom", method="qme", probs=1/2, start=list(prob=1/2), control=list(trace=1, REPORT=1)) initial value 16.000000 iter 2 value 4.000000 iter 2 value 4.000000 iter 2 value 4.000000 final value 4.000000 converged Fitting of the distribution ' geom ' by matching quantiles Parameters: estimate prob 0.276 > fitdist(x, "geom", method="qme", probs=1/2, start=list(prob=1/20), control=list(trace=1, REPORT=1)) initial value 81.000000 iter 1 value 81.000000 final value 81.000000 converged Fitting of the distribution ' geom ' by matching quantiles Parameters: estimate prob 0.05 > > proc.time() user system elapsed 7.17 0.20 7.35