## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 6,
  fig.height = 4,
  warning = FALSE,
  message = FALSE
)

## ----setup--------------------------------------------------------------------
library(gpci)
library(ggplot2)

## ----sim-data-----------------------------------------------------------------
set.seed(123)
process_data <- rnorm(100, mean = 9.8, sd = 1.1)

## ----capability-fit-----------------------------------------------------------
# Create standard normal distribution template
dist_norm <- dist_normal()

# Compute capability indices (moment-based and quantile-based)
fit <- capability(
  data = process_data,
  distribution = dist_norm,
  USL = 13,
  LSL = 7,
  target = 10,
  indices = c("Cp", "Cpk", "Cpl", "Cpu", "Cpm", "Cpmk", "Spmk", "Cpc"),
  fit = TRUE,
  fit_method = "mle",
  mode = "moments"
)

# Print results
print(fit)

## ----bootstrap-ci-------------------------------------------------------------
# Calculate CIs
ci <- boot_ci(
  fit = fit,
  B = 30, # Optimized B for fast vignette generation
  alpha = c(0.10, 0.05, 0.01),
  method = "percentile",
  type = "parametric"
)

# View CI table
print(ci)

## ----plot-density-------------------------------------------------------------
plot(fit, type = "density")

## ----plot-cdf-----------------------------------------------------------------
plot(fit, type = "cdf")

## ----plot-qq------------------------------------------------------------------
plot(fit, type = "qq")

## ----plot-run-----------------------------------------------------------------
plot(fit, type = "run")

## ----plot-boot----------------------------------------------------------------
plot(ci, type = "boot")

## ----plot-forest--------------------------------------------------------------
plot(ci, type = "forest")

