Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Challenge: Solving the Task Using Bayes' Theorem | Probability of Complex Events
Probability Theory Basics

book
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.

  1. Calculate the probability that a randomly selected person has a heart problem.
  2. Calculate the probability that the randomly selected person has a stomachache.
  3. Calculate the probability that you randomly select a person that has diabetes.

Soluzione

# 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?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 6
# 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

expand
ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

some-alt