## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 6,
  fig.height = 4
)
library(ModToppLeone)

## ----core_funcs---------------------------------------------------------------
# Density and CDF
dmtl(x = 1.0, alpha = 1.5)
pmtl(q = 1.0, alpha = 1.5)

# Quantile function and Random Generation
qmtl(p = c(0.25, 0.50, 0.75), alpha = 1.5)

set.seed(123)
sample_data <- rmtl(n = 10, alpha = 1.5)
sample_data

# Survival and Hazard Rate Functions
smtl(x = 1.0, alpha = 1.5)
hmtl(x = 1.0, alpha = 1.5)

## ----properties---------------------------------------------------------------
# Mode and Mean
mode_mtl(alpha = 2.5)
mean_mtl(alpha = 1.5)

# Quantiles summary (Median, Skewness, Kurtosis)
quantiles_mtl(alpha = 1.5)

# Mean Deviations about mean and median
meandev_mtl(alpha = 1.5)

# Stress-Strength Reliability P(Y2 < Y1)
ssr_mtl(alpha1 = 2, alpha2 = 3)

## ----classical_fit------------------------------------------------------------
set.seed(42)
sim_data <- rmtl(n = 50, alpha = 2.0)

# Unified estimation wrapper
fit_results <- fit_mtl(x = sim_data, method = "all")
fit_results

## ----bayes_fit----------------------------------------------------------------
# Non-informative prior Bayesian estimation
bayes_res <- bayes_mtl(x = sim_data, prior = "noninformative", loss = "all")
bayes_res$estimates
bayes_res$hpd

## ----censoring----------------------------------------------------------------
# Progressive Type-II Censoring example
R_scheme <- c(2, 0, 1, 0, 2)
prog_sample <- rcensor_mtl(n = 10, alpha = 2.0, scheme = "progressive2", m = 5, R = R_scheme)

mle_censor_mtl(x = prog_sample$x, scheme = "progressive2", R = R_scheme)

## ----datasets-----------------------------------------------------------------
data(dataset_air)
mle_mtl(dataset_air)

