Created
October 15, 2021 15:13
-
-
Save svmiller/41b678b9d189ec040ecabc3042b75457 to your computer and use it in GitHub Desktop.
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(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