R/core.R

bootstrap <- function (n, Bayesian=F, weights=NULL)
{
  if(Bayesian)
  {
    u <- c(0,sort(stats::runif(n-1)),1)
    u <- (u[-1] - u[-length(u)])*n
    if(!is.null(weights)) u <- u*weights*n/sum(u*weights)
  }
  else
  {
    if(is.null(weights)) weights <-rep(1/n,n)
    u <- stats::rmultinom(1,n,weights)
  }
  as.vector(u)
}
resplab/predtools documentation built on July 2, 2023, 2:58 a.m.