% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/invertDnDraws.R
\name{invertDnDraws}
\alias{invertDnDraws}
\title{Invert Dn draws to kmax(Da)}
\usage{
invertDnDraws(draws, Da, weights, p = c(0.05, 0.1, 0.16, 0.84, 0.9, 0.95))
}
\arguments{
\item{draws}{data.table(ky, s, Dn, IDn) — Dn in cm}

\item{Da}{numeric vector — displacement targets in cm}

\item{weights}{named numeric vector, ensemble weights by IDn}

\item{p}{numeric quantiles in (0,1) to report alongside the mean.
Default c(0.05, 0.10, 0.16, 0.84, 0.90, 0.95). The output
always includes the ensemble mean as the first p row.}
}
\value{
data.table(Da, p, kmax). Column \code{p} is character: "mean" or the
numeric quantile formatted as "0.84", "0.90", etc.
}
\description{
For each realisation s, inverts each model's Dn(ky) curve to kmax(Da),
builds weighted ensemble mean, then averages over realisations.
}
\details{
Log-log linear extrapolation is used when Da falls outside the support of
the computed Dn(ky) curve. No calibration-range clamping is applied — the
natural support of the curve bounds the inversion.

All inputs must be in the same displacement units (cm).
}
\examples{
\dontrun{
uhs <- data.table::fread(
  system.file("extdata", "uhs.csv", package = "newmark"))
out <- fitDnCurve(uhs, ky = getDnKy(uhs, Ts = 0.3), Ts = 0.3, Mw = 7.5,
                  NS = 100,
                  weights = c(AM88=1, BT07=1, SR08=1, BM17=1))
invertDnDraws(out$draws, Da = c(2.5, 5, 10),
              weights = c(AM88=1, BT07=1, SR08=1, BM17=1))
}
}
