R/cumulate_matrix.R

#' Converts a transition matrix into a 'cumulative transition matrix'

#' If A is a matrix, the rows of the cumulative A are the cumulative
#' sums of the rows of A
#' This helps in the computation of the probability of an event happening
#' @param transition_matrix The transition matrix for the Markov model, a table
#' @return A table that is the cumulative version of the input table
#' @export
cumulate_matrix <- function(transition_matrix)
{
  cum_matrix <- t(apply(transition_matrix, 1, cumsum))
  return(cum_matrix)
}
sams25/rcombinator_old documentation built on May 28, 2019, 8:40 a.m.