class: center, middle, inverse, title-slide # discrete probability ## Using flipbookr and xaringan ### Me --- <style type="text/css"> .remark-code{line-height: 1.5; font-size: 70%} @media print { .has-continuation { display: block; } } code.r.hljs.remark-code{ position: relative; overflow-x: hidden; } code.r.hljs.remark-code:hover{ overflow-x:visible; width: 500px; border-style: solid; } </style> --- count: false .panel1-setup-auto[ ```r *knitr::opts_chunk$set(echo = TRUE) ``` ] .panel2-setup-auto[ ] <style> .panel1-setup-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-setup-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-setup-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .panel1-roulette-auto[ ```r *library(tidyverse) ``` ] .panel2-roulette-auto[ ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) *c(3800, 200, 0, -100, - 300) ``` ] .panel2-roulette-auto[ ``` [1] 3800 200 0 -100 -300 ``` ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% * data.frame(payout = .) ``` ] .panel2-roulette-auto[ ``` payout 1 3800 2 200 3 0 4 -100 5 -300 ``` ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% * mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) ``` ] .panel2-roulette-auto[ ``` payout prob 1 3800 0.02631579 2 200 0.13157895 3 0 0.15789474 4 -100 0.31578947 5 -300 0.36842105 ``` ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% * mutate(ev_contribution = prob*payout) ``` ] .panel2-roulette-auto[ ``` payout prob ev_contribution 1 3800 0.02631579 100.00000 2 200 0.13157895 26.31579 3 0 0.15789474 0.00000 4 -100 0.31578947 -31.57895 5 -300 0.36842105 -110.52632 ``` ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% * mutate(ev = sum(ev_contribution)) ``` ] .panel2-roulette-auto[ ``` payout prob ev_contribution ev 1 3800 0.02631579 100.00000 -15.78947 2 200 0.13157895 26.31579 -15.78947 3 0 0.15789474 0.00000 -15.78947 4 -100 0.31578947 -31.57895 -15.78947 5 -300 0.36842105 -110.52632 -15.78947 ``` ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% * mutate(var_contribution = (payout - ev)^2 * prob ) ``` ] .panel2-roulette-auto[ ``` payout prob ev_contribution ev var_contribution 1 3800 0.02631579 100.00000 -15.78947 383164.45546 2 200 0.13157895 26.31579 -15.78947 6126.98644 3 0 0.15789474 0.00000 -15.78947 39.36434 4 -100 0.31578947 -31.57895 -15.78947 2239.39350 5 -300 0.36842105 -110.52632 -15.78947 29759.44015 ``` ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% * mutate(variance = sum(var_contribution)) ``` ] .panel2-roulette-auto[ ``` payout prob ev_contribution ev var_contribution variance 1 3800 0.02631579 100.00000 -15.78947 383164.45546 421329.6 2 200 0.13157895 26.31579 -15.78947 6126.98644 421329.6 3 0 0.15789474 0.00000 -15.78947 39.36434 421329.6 4 -100 0.31578947 -31.57895 -15.78947 2239.39350 421329.6 5 -300 0.36842105 -110.52632 -15.78947 29759.44015 421329.6 ``` ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% * mutate(sd = sqrt(variance)) ``` ] .panel2-roulette-auto[ ``` payout prob ev_contribution ev var_contribution variance sd 1 3800 0.02631579 100.00000 -15.78947 383164.45546 421329.6 649.0991 2 200 0.13157895 26.31579 -15.78947 6126.98644 421329.6 649.0991 3 0 0.15789474 0.00000 -15.78947 39.36434 421329.6 649.0991 4 -100 0.31578947 -31.57895 -15.78947 2239.39350 421329.6 649.0991 5 -300 0.36842105 -110.52632 -15.78947 29759.44015 421329.6 649.0991 ``` ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> *roulette_example ``` ] .panel2-roulette-auto[ ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> roulette_example *roulette_example ``` ] .panel2-roulette-auto[ ``` payout prob ev_contribution ev var_contribution variance sd 1 3800 0.02631579 100.00000 -15.78947 383164.45546 421329.6 649.0991 2 200 0.13157895 26.31579 -15.78947 6126.98644 421329.6 649.0991 3 0 0.15789474 0.00000 -15.78947 39.36434 421329.6 649.0991 4 -100 0.31578947 -31.57895 -15.78947 2239.39350 421329.6 649.0991 5 -300 0.36842105 -110.52632 -15.78947 29759.44015 421329.6 649.0991 ``` ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> roulette_example roulette_example %>% * ggplot() ``` ] .panel2-roulette-auto[ ![](discrete_probability_flipbook_files/figure-html/roulette_auto_12_output-1.png)<!-- --> ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> roulette_example roulette_example %>% ggplot() + * aes(x = payout, y = prob) ``` ] .panel2-roulette-auto[ ![](discrete_probability_flipbook_files/figure-html/roulette_auto_13_output-1.png)<!-- --> ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> roulette_example roulette_example %>% ggplot() + aes(x = payout, y = prob) + * geom_point() ``` ] .panel2-roulette-auto[ ![](discrete_probability_flipbook_files/figure-html/roulette_auto_14_output-1.png)<!-- --> ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> roulette_example roulette_example %>% ggplot() + aes(x = payout, y = prob) + geom_point() + * geom_segment(aes(xend = payout, yend = 0)) ``` ] .panel2-roulette-auto[ ![](discrete_probability_flipbook_files/figure-html/roulette_auto_15_output-1.png)<!-- --> ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> roulette_example roulette_example %>% ggplot() + aes(x = payout, y = prob) + geom_point() + geom_segment(aes(xend = payout, yend = 0)) + * geom_rect(aes(xmin = 0, xmax = payout, * ymin = 0, ymax = prob), * alpha = .2) ``` ] .panel2-roulette-auto[ ![](discrete_probability_flipbook_files/figure-html/roulette_auto_16_output-1.png)<!-- --> ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> roulette_example roulette_example %>% ggplot() + aes(x = payout, y = prob) + geom_point() + geom_segment(aes(xend = payout, yend = 0)) + geom_rect(aes(xmin = 0, xmax = payout, ymin = 0, ymax = prob), alpha = .2) + * geom_vline(xintercept = -15.789, linetype = "dashed") ``` ] .panel2-roulette-auto[ ![](discrete_probability_flipbook_files/figure-html/roulette_auto_17_output-1.png)<!-- --> ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> roulette_example roulette_example %>% ggplot() + aes(x = payout, y = prob) + geom_point() + geom_segment(aes(xend = payout, yend = 0)) + geom_rect(aes(xmin = 0, xmax = payout, ymin = 0, ymax = prob), alpha = .2) + geom_vline(xintercept = -15.789, linetype = "dashed") -> *picture_ev ``` ] .panel2-roulette-auto[ ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> roulette_example roulette_example %>% ggplot() + aes(x = payout, y = prob) + geom_point() + geom_segment(aes(xend = payout, yend = 0)) + geom_rect(aes(xmin = 0, xmax = payout, ymin = 0, ymax = prob), alpha = .2) + geom_vline(xintercept = -15.789, linetype = "dashed") -> picture_ev *roulette_example ``` ] .panel2-roulette-auto[ ``` payout prob ev_contribution ev var_contribution variance sd 1 3800 0.02631579 100.00000 -15.78947 383164.45546 421329.6 649.0991 2 200 0.13157895 26.31579 -15.78947 6126.98644 421329.6 649.0991 3 0 0.15789474 0.00000 -15.78947 39.36434 421329.6 649.0991 4 -100 0.31578947 -31.57895 -15.78947 2239.39350 421329.6 649.0991 5 -300 0.36842105 -110.52632 -15.78947 29759.44015 421329.6 649.0991 ``` ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> roulette_example roulette_example %>% ggplot() + aes(x = payout, y = prob) + geom_point() + geom_segment(aes(xend = payout, yend = 0)) + geom_rect(aes(xmin = 0, xmax = payout, ymin = 0, ymax = prob), alpha = .2) + geom_vline(xintercept = -15.789, linetype = "dashed") -> picture_ev roulette_example %>% * ggplot() ``` ] .panel2-roulette-auto[ ![](discrete_probability_flipbook_files/figure-html/roulette_auto_20_output-1.png)<!-- --> ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> roulette_example roulette_example %>% ggplot() + aes(x = payout, y = prob) + geom_point() + geom_segment(aes(xend = payout, yend = 0)) + geom_rect(aes(xmin = 0, xmax = payout, ymin = 0, ymax = prob), alpha = .2) + geom_vline(xintercept = -15.789, linetype = "dashed") -> picture_ev roulette_example %>% ggplot() + * aes(x = payout - ev, y = payout - ev) ``` ] .panel2-roulette-auto[ ![](discrete_probability_flipbook_files/figure-html/roulette_auto_21_output-1.png)<!-- --> ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> roulette_example roulette_example %>% ggplot() + aes(x = payout, y = prob) + geom_point() + geom_segment(aes(xend = payout, yend = 0)) + geom_rect(aes(xmin = 0, xmax = payout, ymin = 0, ymax = prob), alpha = .2) + geom_vline(xintercept = -15.789, linetype = "dashed") -> picture_ev roulette_example %>% ggplot() + aes(x = payout - ev, y = payout - ev) + * geom_point() ``` ] .panel2-roulette-auto[ ![](discrete_probability_flipbook_files/figure-html/roulette_auto_22_output-1.png)<!-- --> ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> roulette_example roulette_example %>% ggplot() + aes(x = payout, y = prob) + geom_point() + geom_segment(aes(xend = payout, yend = 0)) + geom_rect(aes(xmin = 0, xmax = payout, ymin = 0, ymax = prob), alpha = .2) + geom_vline(xintercept = -15.789, linetype = "dashed") -> picture_ev roulette_example %>% ggplot() + aes(x = payout - ev, y = payout - ev) + geom_point() + * coord_equal() ``` ] .panel2-roulette-auto[ ![](discrete_probability_flipbook_files/figure-html/roulette_auto_23_output-1.png)<!-- --> ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> roulette_example roulette_example %>% ggplot() + aes(x = payout, y = prob) + geom_point() + geom_segment(aes(xend = payout, yend = 0)) + geom_rect(aes(xmin = 0, xmax = payout, ymin = 0, ymax = prob), alpha = .2) + geom_vline(xintercept = -15.789, linetype = "dashed") -> picture_ev roulette_example %>% ggplot() + aes(x = payout - ev, y = payout - ev) + geom_point() + coord_equal() + * geom_segment(aes(xend = payout - ev, yend = 0)) ``` ] .panel2-roulette-auto[ ![](discrete_probability_flipbook_files/figure-html/roulette_auto_24_output-1.png)<!-- --> ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> roulette_example roulette_example %>% ggplot() + aes(x = payout, y = prob) + geom_point() + geom_segment(aes(xend = payout, yend = 0)) + geom_rect(aes(xmin = 0, xmax = payout, ymin = 0, ymax = prob), alpha = .2) + geom_vline(xintercept = -15.789, linetype = "dashed") -> picture_ev roulette_example %>% ggplot() + aes(x = payout - ev, y = payout - ev) + geom_point() + coord_equal() + geom_segment(aes(xend = payout - ev, yend = 0)) + * geom_rect(aes(xmin = ev, xmax = payout - ev, * ymin = 0, ymax = payout - ev, * alpha = prob)) ``` ] .panel2-roulette-auto[ ![](discrete_probability_flipbook_files/figure-html/roulette_auto_25_output-1.png)<!-- --> ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> roulette_example roulette_example %>% ggplot() + aes(x = payout, y = prob) + geom_point() + geom_segment(aes(xend = payout, yend = 0)) + geom_rect(aes(xmin = 0, xmax = payout, ymin = 0, ymax = prob), alpha = .2) + geom_vline(xintercept = -15.789, linetype = "dashed") -> picture_ev roulette_example %>% ggplot() + aes(x = payout - ev, y = payout - ev) + geom_point() + coord_equal() + geom_segment(aes(xend = payout - ev, yend = 0)) + geom_rect(aes(xmin = ev, xmax = payout - ev, ymin = 0, ymax = payout - ev, alpha = prob)) + * geom_rect(aes(xmin = 0, ymin = 0, xmax = sd, ymax = sd), * fill = "darkred") ``` ] .panel2-roulette-auto[ ![](discrete_probability_flipbook_files/figure-html/roulette_auto_26_output-1.png)<!-- --> ] --- count: false .panel1-roulette-auto[ ```r library(tidyverse) c(3800, 200, 0, -100, - 300) %>% data.frame(payout = .) %>% mutate(prob = c(1/38, 5/38, 6/38, 12/38, 14/38)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> roulette_example roulette_example %>% ggplot() + aes(x = payout, y = prob) + geom_point() + geom_segment(aes(xend = payout, yend = 0)) + geom_rect(aes(xmin = 0, xmax = payout, ymin = 0, ymax = prob), alpha = .2) + geom_vline(xintercept = -15.789, linetype = "dashed") -> picture_ev roulette_example %>% ggplot() + aes(x = payout - ev, y = payout - ev) + geom_point() + coord_equal() + geom_segment(aes(xend = payout - ev, yend = 0)) + geom_rect(aes(xmin = ev, xmax = payout - ev, ymin = 0, ymax = payout - ev, alpha = prob)) + geom_rect(aes(xmin = 0, ymin = 0, xmax = sd, ymax = sd), fill = "darkred") -> *picture_variance ``` ] .panel2-roulette-auto[ ] <style> .panel1-roulette-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-roulette-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-roulette-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .panel1-insurance-auto[ ```r *c(20000, 5000, 0) ``` ] .panel2-insurance-auto[ ``` [1] 20000 5000 0 ``` ] --- count: false .panel1-insurance-auto[ ```r c(20000, 5000, 0) %>% * data.frame(payout = .) ``` ] .panel2-insurance-auto[ ``` payout 1 20000 2 5000 3 0 ``` ] --- count: false .panel1-insurance-auto[ ```r c(20000, 5000, 0) %>% data.frame(payout = .) %>% * mutate(situation = c("car totaled", * "car repairs", * "no accidents")) ``` ] .panel2-insurance-auto[ ``` payout situation 1 20000 car totaled 2 5000 car repairs 3 0 no accidents ``` ] --- count: false .panel1-insurance-auto[ ```r c(20000, 5000, 0) %>% data.frame(payout = .) %>% mutate(situation = c("car totaled", "car repairs", "no accidents")) %>% * mutate(prob = c(1/100, 9/100, 90/100)) ``` ] .panel2-insurance-auto[ ``` payout situation prob 1 20000 car totaled 0.01 2 5000 car repairs 0.09 3 0 no accidents 0.90 ``` ] --- count: false .panel1-insurance-auto[ ```r c(20000, 5000, 0) %>% data.frame(payout = .) %>% mutate(situation = c("car totaled", "car repairs", "no accidents")) %>% mutate(prob = c(1/100, 9/100, 90/100)) %>% * mutate(ev_contribution = prob*payout) ``` ] .panel2-insurance-auto[ ``` payout situation prob ev_contribution 1 20000 car totaled 0.01 200 2 5000 car repairs 0.09 450 3 0 no accidents 0.90 0 ``` ] --- count: false .panel1-insurance-auto[ ```r c(20000, 5000, 0) %>% data.frame(payout = .) %>% mutate(situation = c("car totaled", "car repairs", "no accidents")) %>% mutate(prob = c(1/100, 9/100, 90/100)) %>% mutate(ev_contribution = prob*payout) %>% * mutate(ev = sum(ev_contribution)) ``` ] .panel2-insurance-auto[ ``` payout situation prob ev_contribution ev 1 20000 car totaled 0.01 200 650 2 5000 car repairs 0.09 450 650 3 0 no accidents 0.90 0 650 ``` ] --- count: false .panel1-insurance-auto[ ```r c(20000, 5000, 0) %>% data.frame(payout = .) %>% mutate(situation = c("car totaled", "car repairs", "no accidents")) %>% mutate(prob = c(1/100, 9/100, 90/100)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% * mutate(var_contribution = (payout - ev)^2 * prob ) ``` ] .panel2-insurance-auto[ ``` payout situation prob ev_contribution ev var_contribution 1 20000 car totaled 0.01 200 650 3744225 2 5000 car repairs 0.09 450 650 1703025 3 0 no accidents 0.90 0 650 380250 ``` ] --- count: false .panel1-insurance-auto[ ```r c(20000, 5000, 0) %>% data.frame(payout = .) %>% mutate(situation = c("car totaled", "car repairs", "no accidents")) %>% mutate(prob = c(1/100, 9/100, 90/100)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% * mutate(variance = sum(var_contribution)) ``` ] .panel2-insurance-auto[ ``` payout situation prob ev_contribution ev var_contribution variance 1 20000 car totaled 0.01 200 650 3744225 5827500 2 5000 car repairs 0.09 450 650 1703025 5827500 3 0 no accidents 0.90 0 650 380250 5827500 ``` ] --- count: false .panel1-insurance-auto[ ```r c(20000, 5000, 0) %>% data.frame(payout = .) %>% mutate(situation = c("car totaled", "car repairs", "no accidents")) %>% mutate(prob = c(1/100, 9/100, 90/100)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% * mutate(sd = sqrt(variance)) ``` ] .panel2-insurance-auto[ ``` payout situation prob ev_contribution ev var_contribution variance sd 1 20000 car totaled 0.01 200 650 3744225 5827500 2414.022 2 5000 car repairs 0.09 450 650 1703025 5827500 2414.022 3 0 no accidents 0.90 0 650 380250 5827500 2414.022 ``` ] --- count: false .panel1-insurance-auto[ ```r c(20000, 5000, 0) %>% data.frame(payout = .) %>% mutate(situation = c("car totaled", "car repairs", "no accidents")) %>% mutate(prob = c(1/100, 9/100, 90/100)) %>% mutate(ev_contribution = prob*payout) %>% mutate(ev = sum(ev_contribution)) %>% mutate(var_contribution = (payout - ev)^2 * prob ) %>% mutate(variance = sum(var_contribution)) %>% mutate(sd = sqrt(variance)) -> *insurance_example ``` ] .panel2-insurance-auto[ ] <style> .panel1-insurance-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-insurance-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-insurance-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style>