calculators
A collection of calculation functions for hazard aggregation.
cov(mean, std)
¶
Calculate the coeficient of variation handling zero mean by setting cov to zero.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mean
|
NDArray
|
array of mean values |
required |
std
|
NDArray
|
array of standard deviation values |
required |
Returns:
Name | Type | Description |
---|---|---|
cov |
NDArray
|
array of coeficient of variation values |
Source code in toshi_hazard_post/calculators.py
60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
prob_to_rate(prob, inv_time)
¶
Convert probability of exceedance to rate assuming Poisson distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prob
|
NDArray
|
probability of exceedance |
required |
inv_time
|
float
|
time period for probability (e.g. 1.0 for annual probability) |
required |
Returns:
Name | Type | Description |
---|---|---|
rate |
NDArray
|
return rate in inv_time |
Source code in toshi_hazard_post/calculators.py
15 16 17 18 19 20 21 22 23 24 25 26 |
|
rate_to_prob(rate, inv_time)
¶
Convert rate to probabiility of exceedance assuming Poisson distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rate
|
NDArray
|
rate over inv_time |
required |
inv_time
|
float
|
time period of rate (e.g. 1.0 for annual rate) |
required |
Returns:
Name | Type | Description |
---|---|---|
prob |
NDArray
|
probability of exceedance in inv_time |
Source code in toshi_hazard_post/calculators.py
29 30 31 32 33 34 35 36 37 38 39 40 |
|
weighted_avg_and_std(values, weights)
¶
Calculate weighted average and standard deviation of an array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
NDArray
|
array of values (branch, IMTL) |
required |
weights
|
NDArray
|
weights of values (branch, ) |
required |
Returns:
Type | Description |
---|---|
Tuple[NDArray, NDArray]
|
A tuple of (mean, std) where mean is the weighted mean and std is the standard devaition both with size (IMTL, ). |
Source code in toshi_hazard_post/calculators.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
weighted_quantiles(values, weights, quantiles)
¶
Calculate weighted quantiles of array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
NDArray
|
values of data |
required |
weights
|
NDArray
|
weights of values. Same length as values |
required |
quantiles
|
Union[list[float], NDArray]
|
quantiles to be found. Values should be in [0,1] |
required |
Returns:
Type | Description |
---|---|
NDArray
|
weighted quantiles |
Source code in toshi_hazard_post/calculators.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|