
Calculate trapezoidal weights for a vector of periods or frequencies
calculate_weight_vector.RdCompute trapezoidal integration weights for a numeric vector of return periods or exceedance frequencies.
Usage
calculate_weight_vector(x, type = c("period", "frequency"))Details
When type = "period", return periods \(T\) are first converted to
exceedance frequencies \(p = 1 / T\).
For frequencies sorted in descending order (\(p_1 > p_2 > \dots > p_n\)), the trapezoidal rule assigns weights:
\(w_1 = (p_1 - p_2) / 2\)
\(w_i = (p_{i-1} - p_{i+1}) / 2\) for \(1 < i < n\)
\(w_n = (p_{n-1} - p_n) / 2\)
If the vector of defined frequencies is not sorted in descending order, the
function sorts them in decreasing order, calls itself recursively with
type = "frequency", and restores the resulting weights to the original order
of the input.
Missing values (NA) are excluded before applying the formula and are
restored at their original positions in the output, ensuring that missing
data do not prevent calculation on valid events.
Author
Frédéric Grelot, frederic.grelot.1994_cran@m4x.org