Skip to contents

Uses a Gaussian copula to draw one spectral-acceleration value at each requested period. Input rows may appear in any order. Output column j always corresponds to Tn[j], and the supplied period order is preserved.

Usage

sampleSaCorr(uhs, Tn, rho, NS)

Arguments

uhs

A quantile data.table with columns Tn, p, and Sa, or an analytic finite-mixture data.table with columns Tn, k, muLn, sigmaLn, and w.

Tn

Numeric vector of requested periods. The first element is the reference period Tn[1], for example 0.01 or 0. It need not be sorted.

rho

Numeric vector of length length(Tn) - 1; correlations between the reference period Tn[1] and each remaining period.

NS

Integer Monte Carlo sample size.

Value

A numeric matrix with NS rows and length(Tn) columns, in the same period order as Tn. Values are spectral accelerations in g.

Details

A quantile-table input needs at least three positive quantile rows at each requested period. Alternatively, an analytic finite mixture may be supplied with columns Tn, k, muLn, sigmaLn, and w. Analytic mixture quantiles are inverted directly; no report probabilities or splines are materialized. When a requested period is not tabulated, its log-quantile function and exact mean are interpolated in log-period space using the same endpoint rule as interpolateSaTable(). Raw OpenQuake fractiles are not a downstream quantile-table contract: first calibrate them with fitSaLognormal() and assemble the returned parameters as one analytic component. Quantile input remains supported for spectra whose distribution is already represented by quantiles, including the current MCE envelope workflow.

Each sample column is rescaled to its supplied or analytic mean exactly. This finite-sample recentering preserves the copula ranks but changes all draws at one period by one constant factor. Use set.seed() when reproducible draws are needed.

Examples

uhs <- data.table::data.table(
  Tn = rep(c(0, 1), each = 4),
  p = rep(c("0.16", "0.50", "0.84", "mean"), 2),
  Sa = c(0.30, 0.48, 0.72, 0.50, 0.10, 0.19, 0.31, 0.20)
)
rho <- rhoBJ(Tn = 1.0, T0 = 0.01)
set.seed(1)
mat <- sampleSaCorr(uhs = uhs, Tn = c(0, 1), rho = rho, NS = 20)
colMeans(mat)
#> [1] 0.5 0.2