Single Risk
Determine non-exceedence probabilities for a single risk.
Import libraries
import sys
import os
import pandas as pd
from darpi.quantitative.plots import plot_histogram_and_cdf, plot_ppf_curve
from darpi.quantitative.probability import (
get_histogram_data,
get_samples,
get_triangular_distribution,
get_empirical_cdf,
get_empirical_ppf,
sum_samples,
)
from darpi.qualitative.plots import plot_empty_heat_map, add_scatter_to_heat_map
Generate probability of non-exceedance charts for one risk
# Identify the risk, cost, and probability of occurrence
risk = "Risk 1"
costs = (1000, 2000, 5000)
probability = 0.6
# Generate the triangular distribution that corresponds with the risk above
distribution = get_triangular_distribution(a=costs[0], b=costs[2], c=costs[1])
# Generate the samples (the default is n==100,000)
data = get_samples(distribution=distribution, risk_probability=probability)
# Get plotting data
hist_data = get_histogram_data(data)
cdf_data = get_empirical_cdf(data)
ppf_data = get_empirical_ppf(data)
# Make some plots
fig = plot_histogram_and_cdf(hist_data=hist_data, cdf_data=cdf_data)
# fig.write_image("images/single-risk-histogram_cdf.png")
fig = plot_ppf_curve(data=ppf_data)
# fig.write_image("images/single-risk-ppf.png")

Generate probability of non-exceedance table for one risk
| cost | p | |
|---|---|---|
| 0 | 0.00 | 0.00 |
| 1 | 0.00 | 0.01 |
| 2 | 0.00 | 0.02 |
| 3 | 0.00 | 0.03 |
| 4 | 0.00 | 0.04 |
| ... | ... | ... |
| 96 | 4099.60 | 0.96 |
| 97 | 4224.11 | 0.97 |
| 98 | 4365.02 | 0.98 |
| 99 | 4554.38 | 0.99 |
| 100 | 4987.99 | 1.00 |
101 rows × 2 columns