Skip to content

Instantly share code, notes, and snippets.

@svmiller
Created October 15, 2021 15:13
Show Gist options
  • Save svmiller/41b678b9d189ec040ecabc3042b75457 to your computer and use it in GitHub Desktop.
Save svmiller/41b678b9d189ec040ecabc3042b75457 to your computer and use it in GitHub Desktop.
library(tidyverse)
library(stevemisc)
jenny()
num_nums <- tibble()
for (i in 1:100) {
tibble(x = runif(50),
runsum = cumsum(x),
lag = lag(runsum),
lag1 = ifelse(is.na(lag), x, lag)) %>%
mutate(seq = 1:n()) %>%
filter(runsum > 1 & lag1 < 1) -> aa
bind_rows(num_nums, aa) -> num_nums
}
mean(num_nums$seq)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment