R/rbn.hssm.R

Defines functions rbn.hssm

Documented in rbn.hssm

#' Random emission from Bayesian network.
#'
#' \code{rbn.hsmm} returns a random sample from the Bayesian network in the
#' given state for the given model.
#'
#' @param state The state of the model.
#' @param model The model.
#'
#' @keywords internal
#'
#' @return A vector with the samples of each node in the Bayesian network.
#'
rbn.hssm <- function(state, model) {
  bn <- model$parms.emission[[state]]
  sample <- bnlearn::cpdist(bn, nodes = bnlearn::nodes(bn), evidence = TRUE, n = 1)

  as.vector(as.matrix(sample))
}

Try the hmma package in your browser

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

hmma documentation built on July 2, 2020, 12:10 a.m.