% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spectra-ossl.R
\name{pi_to_confidence}
\alias{pi_to_confidence}
\title{Map a 95\% prediction interval to a [0, 1] confidence score}
\usage{
pi_to_confidence(pi95_low, pi95_high, value = NULL)
}
\arguments{
\item{pi95_low}{Lower 2.5\% quantile of the prediction.}

\item{pi95_high}{Upper 97.5\% quantile of the prediction.}

\item{value}{Optional point prediction. When supplied, normalisation
is by \code{|value|}; otherwise by \code{|midpoint|}.}
}
\value{
Numeric in \code{[0, 1]}.
}
\description{
Tightens confidence as the prediction interval narrows relative to
the predicted value: \code{confidence = 1 - (PI95_width / |value|) / 4},
floored at 0 and capped at 1. When \code{value} is near zero we
fall back to an absolute-width heuristic so we never blow up.
}
\details{
Properties of the mapping:
\itemize{
  \item Zero-width interval -> confidence = 1.
  \item Interval whose width equals \code{|value| * 4} -> confidence = 0.
  \item NA value or NA bounds -> confidence = 0.5 (neutral).
}
}
