R/get_distribution.R

Defines functions get_distribution.fars_density get_distribution

Documented in get_distribution get_distribution.fars_density

#' @title Generic Function to Extract Distribution 
#'
#' @param object An object from which to extract the distribution.
#' @param ... Additional arguments (ignored).
#'
#' @return A matrix containing the random draws from the fitted skew-t distribution.
#'
#' @examples
#' \donttest{
#' fars_density_result <- compute_density(
#'   quantiles = matrix(rnorm(100 * 5), nrow = 100, ncol = 5)
#' )
#' get_distribution(fars_density_result)
#' }
#'
#' @export
get_distribution <- function(object, ...) {
  UseMethod("get_distribution")
}

#' @title Extract Distribution from a \code{fars_density} Object
#'
#' @description Extracts the distribution from a \code{fars_density} object. 
#'
#' @param object An object of class \code{fars_density}.
#' @param ... Further arguments (ignored).
#'
#' @return A matrix containing the random draws from the fitted skew-t distribution if available, otherwise NULL.
#'
#' @examples
#' \donttest{
#' fars_density_result <- compute_density(quantiles = matrix(rnorm(100 * 5), nrow = 100, ncol = 5))
#' get_distribution(fars_density_result)
#'}
#' @export
get_distribution.fars_density <- function(object, ...) {
  if (!is.null(object$distribution)) {
    return(object$distribution)
  }
  NULL
}

Try the FARS package in your browser

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

FARS documentation built on Feb. 17, 2026, 5:06 p.m.