Challenge: Solving the Task Using Bayes' Theorem
Compito
Swipe to start coding
Imagine that we decided to conduct medical research.
You gathered data about two groups: 750
people with heart problems and 800
with chronic stomachache.
You know that 7%
of interviewed from the first group have diabetes; meanwhile, 12%
of respondents from the second group have diabetes too.
Calculate the probability that a randomly selected person with diabetes has a chronic stomachache.
We can use Bayes' theorem to calculate the corresponding probability.
- Calculate the probability that a randomly selected person has a heart problem.
- Calculate the probability that the randomly selected person has a stomachache.
- Calculate the probability that you randomly select a person that has diabetes.
Soluzione
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Probability that ramdomly selected person has heart problem
P_heart = 750 / 1550
# Probability that ramdomly selected person has stomachache
P_stomach = 800 / 1550
P_heart_diabetes = 0.07
P_stomach_diabetes = 0.12
# Probability that you randomly select a person that has diabetes
P_random_diabetes = P_heart * P_heart_diabetes + P_stomach * P_stomach_diabetes
# Randomly selected person with diabetes has chronic stomachache
P_diabetes_belong_stomach = (P_stomach * P_stomach_diabetes)/P_random_diabetes
print(f'The probability is {P_diabetes_belong_stomach:.4f}')
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 2. Capitolo 6
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Probability that randomly selected person has heart problem
P_heart = ___ / 1550
# Probability that randomly selected person has stomachache
P_stomach = ___
P_heart_diabetes = 0.07
P_stomach_diabetes = 0.12
# Probability that you randomly select a person that has diabetes
P_random_diabetes = ___ * P_heart_diabetes + P_stomach * ___
# Randomly selected person with diabetes has chronic stomachache
P_diabetes_belong_stomach = (P_stomach * P_stomach_diabetes)/P_random_diabetes
print(f'The probability is {P_diabetes_belong_stomach:.4f}')
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione