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) | |
fun <- function(x) { | |
if (any(x$Species == "setosa")) { | |
tail(x, n = 3) |> select(Petal.Length) | |
} else { | |
head(x, n = 3) |> select(Petal.Length) | |
} | |
} |
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) | |
#Flip 100 coins, labeled 1 through 100. Alice checks the coins in order (1, 2, 3, …) while Bob checks the odd-labeled coins, #then the even-labeled ones (so 1, 3, 5, …, 99, 2, 4, 6, …). Who is more likely to see two heads *first*? | |
library(tidyverse) | |
flip_coin <- function(){ | |
flip_coin_tbl <- tibble( |
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
# https://gilkalai.wordpress.com/2009/07/08/test-your-intuition-7/ | |
#Consider the following game: you have a box that contains one white ball and one black ball. | |
#You choose a ball at random and then return it to the box. | |
#If you chose a white ball then a white ball is added to the box, and if you chose a black ball then a black ball is added to the box. | |
#Played over time, what is the probability that more than 80 percents of the chosen balls are white? | |
library(tidyverse) | |
## make simulation functions -- I couldhave done it one go but just made it more modular |
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
## riddle here https://gilkalai.wordpress.com/2024/09/03/test-your-intuition-56-fifteen-boxes-puzzle/ | |
library(tidyverse) | |
choose_box <- function(){ | |
# create search order | |
andrew <- 1:15 |
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
#You have 3 urns, each containing 100 balls. | |
#In the first two, 99 of the balls are red and the last is green. | |
#In the third urn, all 100 balls are red. | |
#You choose one of the urns at random and remove 99 randomly chosen balls from it; they’re all red. | |
#The last is probably? | |
library(tidyverse) | |
pick_ball <- function(){ |
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
##You have 10000 coins. 9999 of them are fair; one is rigged so that it always lands on heads. | |
##You choose a coin at random and flip it 10 times; it’s heads all ten times. | |
## what is likelihood that the coin is rigged? | |
ht_list <- rep(list(c("H", "T")), 9999) | |
ht_list[[10000]] <- c("H", "H") |
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
hi! | |
Thank you again for taking a look -- I'm trying to improve my simulation skills and curious where I might have the logic or intuition wrong with this riddler exercise | |
```{r} | |
library(tidyverse) | |
total_minutes <- 3*180 |