Skip to article frontmatterSkip to article content

1. Bayes theorem for events

Authors
Affiliations
TNO
TNO
TNO

Define the Known Probabilities

We will start by defining the probabilities given in the problem statement.

# Probability that a structure is affected by corrosion
p_corrosion = 0.01  # 1 in 100

# Probability of a positive test result given that there is corrosion
p_positive_given_corrosion = 0.99  # 99% detection rate

# Probability of a positive test result given that there is no corrosion
p_positive_given_no_corrosion = 0.05  # 5% false positive rate

Calculate the Total Probability of a Positive Test Result

Next, we need to calculate the total probability of a positive test result, which includes both true positives and false positives.

## Write your code here
p_positive = ...

Apply Bayes’ Theorem

Now, we can apply Bayes’ theorem to find the probability that a structure is affected by corrosion given a positive test result.

P(corrosionpositve)=P(positivecorrosion)P(corrosion)P(positive)P(\text{corrosion}|\text{positve}) = \frac{P(\text{positive}|\text{corrosion})P(\text{corrosion})}{P(\text{positive})}

## Write your code here

p_corrosion_given_positive = ...