Skip to contents

calculate_weight() calculates the weight that will be used to estimate expected annual damages, depending on either return period or frequency of lood scenarios.

calculate_weight() can do this for flood scenarios in any order. This has more interest if x is a named vector.

Usage

calculate_weight(x, type = c("period", "frequency"))

Arguments

x

numeric, values of return period of frequency for flood scenarios.

type

character,

Value

numeric, values of weight for flood scenarios

Author

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

Examples


x = c(1, 5, 10, 100, 1000)
calculate_weight(x)
#> [1] 0.4000 0.4500 0.0950 0.0495 0.0045
calculate_weight(1/x, "frequency")
#> [1] 0.4000 0.4500 0.0950 0.0495 0.0045

names(x) = c("deb", "frequent", "medium", "rare", "extreme")
x = rev(c(x, inf = +Inf))
calculate_weight(x)
#>      inf  extreme     rare   medium frequent      deb 
#>   0.0005   0.0050   0.0495   0.0950   0.4500   0.4000 
calculate_weight(1/x, "frequency")
#>      inf  extreme     rare   medium frequent      deb 
#>   0.0005   0.0050   0.0495   0.0950   0.4500   0.4000 

# When the range of flood scenarios goes from 1 to +Inf weights sum to 1
sum(calculate_weight(x))
#> [1] 1

x = sample(x, 6)
calculate_weight(x)
#> frequent   medium     rare      inf  extreme      deb 
#>   0.4500   0.0950   0.0495   0.0005   0.0050   0.4000