This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(gganimate) | |
# Grid for plotting | |
x <- seq(0,10, length.out = 1e3) | |
# Sample Sizes | |
n <- 1:20 | |
# Create the densities at each value of the grid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(gganimate) | |
sample_size <- seq(5, 30, by=5) | |
create_data <- function(sample_size){ | |
tibble(ss=sample_size, n=1:1e6, x=map(n, ~runif(sample_size))) %>% | |
mutate(mean = map_dbl(x, mean), | |
median = map_dbl(x, median), | |
range = map_dbl(x, ~(max(.x) - min(.x))/2)) %>% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(gganimate) | |
set.seed(8) | |
grid <- seq(-5,12, by=0.01) | |
x <- seq(-3,9, by=1) | |
y <- x^2 + rnorm(n=length(x), sd=30) | |
data <-tibble(x=x, y=y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(glue) | |
library(gganimate) | |
grid <- seq(-10,5,length.out=1e4) | |
y <- (grid + 2)^2 + 3 | |
plot_data <- tibble(grid, y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(gganimate) | |
library(magick) | |
# Number of Bern trials to run | |
n_trials <- 100 | |
# Grid for plotting posterior | |
x <- seq(0,1, length.out = 500) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidymodels) | |
library(tidyverse) | |
library(discrim) | |
library(gganimate) | |
# grid size | |
n <- 100 | |
parabolic_grid <- | |
expand.grid(X1 = seq(-5, 5, length = n), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
set.seed(1) | |
df <- tibble(x=rnorm(2000), | |
y=rnorm(2000)) %>% | |
mutate(flag = x+y > 1.5) | |
df %>% | |
ggplot() + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(gganimate) | |
set.seed(777) | |
points <- 2* 1e3 | |
x <- runif(points, min = -1, max=1) | |
y <- runif(points, min=-1, max=1) | |
inside <- x^2 + y^2 < 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Using manim community edition | |
from manim import * | |
config.frame_width = 22 | |
text1 = MathTex(r"\begin{bmatrix} 3 & 9 & 5 \\ 9 & 4 & 2 \\ 7 & 3 & 6 \end{bmatrix} \begin{bmatrix} 5 & 7 & 2 & 4 \\ 3 & 6 & 9 & 8 \\ 2 & 7 & 1 & 4 \end{bmatrix}") | |
text2 = MathTex(r"\begin{bmatrix} 3 & 9 & 5 \\ 9 & 4 & 2 \\ 7 & 3 & 6 \end{bmatrix} \begin{bmatrix} 5 & 7 & 2 & 4 \\ 3 & 6 & 9 & 8 \\ 2 & 7 & 1 & 4 \end{bmatrix}", r"&=", r"\begin{bmatrix} 3 \\ 9 \\ 7 \end{bmatrix} \begin{bmatrix} 5 & 7 & 2 & 4 \end{bmatrix} + \begin{bmatrix} 9 \\ 4 \\ 3 \end{bmatrix} \begin{bmatrix} 3 & 6 & 9 & 8 \end{bmatrix} + \begin{bmatrix} 5 \\ 2 \\ 6 \end{bmatrix} \begin{bmatrix} 2 & 7 & 1 & 4 \end{bmatrix} \\") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gen_dataset <- function(){ | |
b0 <- 3 | |
b1 <- 7 | |
x <- 1:10 | |
linear_predictor <- b0 + b1*x | |
y <- rnorm(n = length(linear_predictor), mean=linear_predictor, sd=8) | |
df <- tibble(x,y) | |
# Fit OLS model | |
ols_model <- lm(y ~ x, data=df) |
OlderNewer