## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(gpciImpSam)

## ----example-fit--------------------------------------------------------------
set.seed(123)
# Simulate 50 observations from a Normal process
process_data <- rnorm(50, mean = 10, sd = 1.2)

# Fit GPCIs using Importance Sampling
fit <- gpci_impsam(
  data = process_data,
  pdf = function(x, mean = 0, sd = 1) dnorm(x, mean = mean, sd = sd),
  cdf = function(x, mean = 0, sd = 1) pnorm(x, mean = mean, sd = sd),
  chain_length = 500,
  burn_in = 100,
  thinning = 1,
  USL = 13.5,
  LSL = 6.5,
  target = 10
)

# Print diagnostic summary table
summary_df <- summary(fit)
knitr::kable(summary_df[, c("Index", "Point_Estimate", "Posterior_Mean", "Bias", "MSE", "Risk_Value", "HPD95_Lower", "HPD95_Upper", "Convergence_Prob")])

## ----plot-density, fig.width = 6, fig.height = 4------------------------------
plot(fit, type = "density", index = "Cpy")

