working through examples of conditional probs

This commit is contained in:
Emanuel Rodriguez 2022-09-03 01:51:37 -07:00
parent e79fd84b94
commit 601bfc9411
1 changed files with 19 additions and 0 deletions

19
R/ch2.R
View File

@ -25,3 +25,22 @@ fake_news|>
tally() |>
mutate(prop = n / sum(n))
# usage of "!" in fake vs real articles
fake_news |>
group_by(type, title_has_excl) |>
summarise(
total_usage_of_excl = n()
) |>
ungroup() |>
group_by(type) |>
summarise(
prop_excl_within_type = total_usage_of_excl / sum(total_usage_of_excl),
title_has_excl
) |>
filter(type == "fake")
# P(A ^ B) = P(A|B)*P(B)
# P(B) = .4
# P(A|B) = .2667
# => P(A|B)*P(B)
.4 * .2667