Skip to contents

Helper function to compute scaled avoided damages for a single parameter draw or a matrix of sampled parameter draws.

Usage

sa_fit_impact(x, b, i)

Arguments

x

Numeric vector (single parameter draw) or numeric matrix (multiple parameter draws in rows) containing stake damage multipliers (first i elements or columns) followed by hydraulic efficiency multipliers.

b

Numeric vector of baseline avoided damages as generated by sa_set_impact_base().

i

Integer scalar, number of stakes (length of the stake multipliers block in x).

Value

If x is a vector, a numeric vector of scaled avoided damages of the same length as b. If x is a matrix, a numeric matrix of dimension nrow(x) x length(b) where each row contains the scaled avoided damages for the corresponding draw.

Details

Given parameter inputs x where stake damage multipliers are positioned first (length i or first i columns) followed by hydraulic efficiency multipliers per flood scenario, this function multiplies the baseline damage vector b element-wise by the corresponding stake and hydraulic multipliers.

If x is a numeric vector (representing a single draw), a scaled damage vector of length length(b) is returned. If x is a numeric matrix (where rows represent multiple sample draws), the computation is vectorized across rows and returns a matrix of dimension nrow(x) x length(b).

Author

Frédéric Grelot, frederic.grelot.1994_cran@m4x.org