## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 6, fig.height = 4, warning = FALSE, message = FALSE ) ## ----setup-------------------------------------------------------------------- library(gpci) library(ggplot2) ## ----define-custom------------------------------------------------------------ # Define custom Weibull distribution template custom_weibull <- define_distribution( name = "custom_weibull", cdf = function(x, shape, scale) pweibull(x, shape = shape, scale = scale), quantile = function(p, shape, scale) qweibull(p, shape = shape, scale = scale), params = list(shape = 2.0, scale = 10.0), # initial parameters support = c(0, Inf) ) ## ----test-pdf----------------------------------------------------------------- # Theoretical PDF at x = 5 (using derived PDF) do.call(custom_weibull$pdf, c(list(5), custom_weibull$params)) # Compare with the built-in dweibull: dweibull(5, shape = 2, scale = 10) ## ----sim-skewed--------------------------------------------------------------- set.seed(42) process_data <- rweibull(80, shape = 2.5, scale = 12.0) ## ----fit-custom--------------------------------------------------------------- fitted_weibull <- fit_distribution( data = process_data, dist = custom_weibull, method = "mle" ) # Print fitted parameters print(fitted_weibull$params) ## ----capability-robust-------------------------------------------------------- fit_robust <- capability( data = process_data, distribution = fitted_weibull, USL = 20, LSL = 3, target = 11, indices = c("Cp_q", "Cpk_q", "CNpk", "CpTk", "Spmk", "CNpmc"), mode = "quantile", fit = FALSE # Already fitted ) print(fit_robust) ## ----plot-robust-density------------------------------------------------------ plot(fit_robust, type = "density") ## ----run-cv, eval = FALSE----------------------------------------------------- # # Evaluate coverage calibration for percentile CIs # cv <- boot_cv( # fit = fit_robust, # B2 = 50, # Number of synthetic samples # B = 200, # Bootstrap reps per synthetic sample # alpha = c(0.10, 0.05), # method = "percentile", # type = "parametric", # parallel = FALSE # ) # # # Print validation metrics (bias, RMSE, empirical coverage vs. nominal) # print(cv)