Created
February 27, 2018 06:47
-
-
Save tvladeck/e7a164dfe70fa765b10c1af64b382b02 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
set.seed(20180226) | |
block_mining_times <- rpois(1000, 10) # lambda = 10 | |
max_time <- sum(block_mining_times) | |
cumulative_times <- cumsum(block_mining_times) | |
rand_times <- runif(1000, min = 0, max = max_time) | |
deltas_between_blocks <- | |
rand_times %>% | |
sapply(function(t){ | |
time_till_next_block <- min((cumulative_times - t)[which(cumulative_times - t > 0)]) | |
time_from_last_block <- min((t - cumulative_times)[which(t - cumulative_times > 0)]) | |
time_till_next_block + time_from_last_block | |
}) | |
# > deltas_between_blocks %>% mean | |
# [1] 10.817 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment