Skip to content

Commit

Permalink
add a meaningfull error message for the zero-likelihood case
Browse files Browse the repository at this point in the history
  • Loading branch information
mnwright committed Jan 17, 2024
1 parent f0ef208 commit c2d7f27
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions R/forge.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ forge <- function(
}
omega <- omega[wt > 0]

if (nrow(omega) == 0) {
stop("All leaves have zero likelihood.")
}

# Draw random leaves with probability proportional to weight
draws <- data.table(
'f_idx' = omega[, sample(f_idx, size = n_synth, replace = TRUE, prob = wt)]
Expand Down

0 comments on commit c2d7f27

Please sign in to comment.