Skip to content

Instantly share code, notes, and snippets.

@druskacik
Created August 27, 2021 14:30
Show Gist options
  • Select an option

  • Save druskacik/a3c548cefa54cb395b4c780cddfc76b4 to your computer and use it in GitHub Desktop.

Select an option

Save druskacik/a3c548cefa54cb395b4c780cddfc76b4 to your computer and use it in GitHub Desktop.
vytvorenie nahodnych dielikov v R-ku
SplitIntoIntervals <- function(start, end, n_intervals = 50) {
margins <- runif(n_intervals - 1, start, end)
margins <- margins[order(margins)]
intervals_start <- c(start, margins)
intervals_end <- c(margins, end)
return(matrix(t(rbind(intervals_start, intervals_end)), ncol = 2))
}
SplitIntoIntervals(-10, 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment