R/CuUpdZ.R

Defines functions CuUpdZ

CuUpdZ <-
  function(mu, m, lambda.r, k.star) {
    k <- length(lambda.r)
    propfz <- purrr::map_dbl(seq.int(k.star,k), function(z){
      logfz <- (z - 1) * log(mu) - lgamma(z) - sum( m[seq_len(z)] * lambda.r[seq_len(z)] )
      # fz <- exp(logfz)
      return(logfz)
    })
    if(length(propfz) == 1) z <- k else{
      z <- sample(x = seq.int(k.star,k), size = 1, prob = as.numeric(Brobdingnag::brob(propfz)/sum(Brobdingnag::brob(propfz))))
    }
    return(z)
  }

Try the BGPhazard package in your browser

Any scripts or data that you put into this service are public.

BGPhazard documentation built on Sept. 3, 2023, 5:09 p.m.