R/prior.R

Defines functions PriorFunction.dirichletprocess PriorFunction

Documented in PriorFunction

#' Generate the prior function of the Dirichlet process
#'
#' @param dpobj A Dirichlet process object
#' @return A function f(x) that represents a draw from the prior distrubtion of the Dirichlet process.
#'
#'  @export
PriorFunction <- function(dpobj) UseMethod("PriorFunction")

#' @export
PriorFunction.dirichletprocess <- function(dpobj){

  prior_clusters <- PriorClusters(dpobj)

  base_function <- function(x, theta) Likelihood(dpobj$mixingDistribution, x, theta)

  prior_func <- weighted_function_generator(base_function,
                                            prior_clusters$weights,
                                            prior_clusters$params)
  return(prior_func)
}

Try the dirichletprocess package in your browser

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

dirichletprocess documentation built on Aug. 25, 2023, 5:19 p.m.