Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Challenge | Probabilities of Several Events
Probability Theory

book
Challenge

Bayes Theorem is crucial for a data scientist, so try to consolidate knowledge!

Tarefa

Swipe to start coding

Imagine that we decided to conduct medical research. You gathered data about two groups of people: 750 people with heart problems and 800 people 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.

  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.
  4. Calculate the probability that a randomly selected person with diabetes has a chronic stomachache (already done).

Solução

# 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("The probability is", P_diabetes_belong_stomach)

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 8
# 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 = ___ * ___ + ___ * ___

# Randomly selected person with diabetes has chronic stomachache
P_diabetes_belong_stomach = (P_stomach * P_stomach_diabetes)/P_random_diabetes

print("The probability is", P_diabetes_belong_stomach)
toggle bottom row
some-alt