calc_pf_beta

Calculates the values of probability of failure or reliability index from the columns of a DataFrame that start with 'I_' (Indicator function). If a .txt file path is passed, this function evaluates pf and β values too.

df_pf, df_beta = calc_pf_beta(df_or_path, numerical_model, n_constraints)

Input variables

Name Description Type
df_or_path The DataFrame containing the columns with boolean values about indicator function, or a path to a .txt file DataFrame or String
numerical_model Containing the numerical model parameters Dictionary
n_constraints Number of state limit functions or constraints Integer

Output variables

Name Description Type
df_pf DataFrame containing the values for probability of failure for each 'I_' column DataFrame
df_beta DataFrame containing the values for beta for each 'I_' column DataFrame

Example 1

Use calc_pf_beta function to process a DataFrame with seven columns: (a) random variable \(x_0\), random variable \(x_1\), random variable \(x_2\), state limit function \(g_0\), state limit function \(x_1\), indicator function \(I_0\), indicator function \(I_1\). Use this function to obtain the probability of failure and the reliability index.

import pandas as pd

from parepy_toolbox import calc_pf_beta

# Dataset
data =  {
            'X_0': [43.519326, 40.184658, 46.269007, 36.370403, 40.089100, 45.000000, 40.000000],
            'X_1': [11.222943, 11.044150, 10.586153, 9.523268, 9.728168, 10.000000, 10.000000],
            'X_2': [0.189671, 0.247242, 0.238284, 0.276446, 0.260700, 0.250000, 0.250000],
            'G_0': [200, 225, -10, 300, 325, -50, 0.01],
            'G_1': [-2, -3, -10, 300, 325, 50, 0.5],
            'I_0': [0, 0, 1, 0, 0, 1, 0],
            'I_1': [1, 1, 1, 0, 0, 0, 0]
        }
df = pd.DataFrame(data)

# Call function
pf_df, beta_df = calc_pf_beta(df, {'model sampling': 'mcs'}, 2)

# Output details: Use the external module tabulate to print pretty
# pip install tabulate or pip install --upgrade tabulate # external library (visit: https://pypi.org/project/tabulate/)
from tabulate import tabulate
print(f'pf:\n{tabulate(pf_df, headers="keys", tablefmt="pretty", showindex=False)}')
print(f'ϐ:\n{tabulate(beta_df, headers="keys", tablefmt="pretty", showindex=False)}')

Output details.

pf:
+--------------------+---------------------+
|        I_0         |         I_1         |
+--------------------+---------------------+
| 0.2857142857142857 | 0.42857142857142855 |
+--------------------+---------------------+
ϐ:
+-------------------+---------------------+
|        I_0        |         I_1         |
+-------------------+---------------------+
| 0.565948821932863 | 0.18001236979270438 |
+-------------------+---------------------+

Example 2

Use calc_pf_beta function to process a txt DataFrame with seven columns: (a) random variable \(x_0\), random variable \(x_1\), random variable \(x_2\), state limit function \(g_0\), state limit function \(x_1\), indicator function \(I_0\), indicator function \(I_1\). Use this function to obtain the probability of failure and the reliability index.

example .txt

X_0	X_1	X_2	G_0	G_1	I_0	I_1
43.519326	11.222943	0.189671	200.0	-2.0	0	1
40.184658	11.04415	0.247242	225.0	-3.0	0	1
46.269007	10.586153	0.238284	-10.0	-10.0	1	1
36.370403	9.523268	0.276446	300.0	300.0	0	0
40.0891	9.728168	0.2607	325.0	325.0	0	0
45.0	10.0	0.25	-50.0	50.0	1	0
40.0	10.0	0.25	0.01	0.5	0	0
import pandas as pd

from parepy_toolbox import calc_pf_beta

# Call function
pf_df, beta_df = calc_pf_beta('./example.txt', {'model sampling': 'mcs'}, 2)

# Output details: Use the external module tabulate to print pretty
# pip install tabulate or pip install --upgrade tabulate # external library (visit: https://pypi.org/project/tabulate/)
from tabulate import tabulate
print(f'pf:\n{tabulate(pf_df, headers="keys", tablefmt="pretty", showindex=False)}')
print(f'ϐ:\n{tabulate(beta_df, headers="keys", tablefmt="pretty", showindex=False)}')

Output details.

pf:
+--------------------+---------------------+
|        I_0         |         I_1         |
+--------------------+---------------------+
| 0.2857142857142857 | 0.42857142857142855 |
+--------------------+---------------------+
ϐ:
+-------------------+---------------------+
|        I_0        |         I_1         |
+-------------------+---------------------+
| 0.565948821932863 | 0.18001236979270438 |
+-------------------+---------------------+