From 601bfc9411f70f84a7ba94132844990d349c4d23 Mon Sep 17 00:00:00 2001 From: ergz Date: Sat, 3 Sep 2022 01:51:37 -0700 Subject: [PATCH] working through examples of conditional probs --- R/ch2.R | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/R/ch2.R b/R/ch2.R index 7694ce4..dd8a069 100644 --- a/R/ch2.R +++ b/R/ch2.R @@ -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