Using your programming language python, write a program that will ask for:
- Probability of A
- Probability of B
- Probability of B given A
and will then output the probability of A given B using Bayes Theorem. You can prompt for the input anyway you like (command line, GUI, website, etc), and return the result any way you like (command line, GUI, website, etc). You may not use any libraries that implement Bayes for you - you need to write that code yourself. Submit your code.
Python code:
probability_A = float(input("Enter probability of A: "))
probability_B = float(input("Enter probability of B: "))
probability_B_given_A = float(input("Enter probability of B given
A: "))
#Bayes theorem states that Probability of A given B =
Probability of B given A * Probability of A / Probability of
B
probability_A_given_B = probability_B_given_A * probability_A /
probability_B
print("Probability of A given B is:
",probability_A_given_B)
Code screenshot:
Output:
Get Answers For Free
Most questions answered within 1 hours.