R/methods_print.R

Defines functions print.jsd_ci print.jsd_estimate

#' @export
print.jsd_estimate <- function(x, ...) {
  cat("Jensen-Shannon Divergence\n")
  cat("Type: ", x$type, "\n", sep = "")
  cat("Estimate: ", formatC(x$estimate, digits = 6, format = "f"), "\n", sep = "")
  invisible(x)
}



#' @export
print.jsd_ci <- function(x, ...) {
  cat("Jensen-Shannon Divergence with Bootstrap CI\n")
  cat("Type:   ", x$type, "\n", sep = "")
  cat("Estimate: ", formatC(x$estimate, digits = 6, format = "f"), "\n", sep = "")
  cat(
    paste0(
      sprintf("%d%% CI: ", round(100 * x$conf_level)),
      "[",
      formatC(x$conf_int["lower"], digits = 6, format = "f"),
      ", ",
      formatC(x$conf_int["upper"], digits = 6, format = "f"),
      "]\n"
    )
  )
  cat("Bootstrap SE:   ", formatC(x$boot_se, digits = 6, format = "f"), "\n", sep = "")
  cat("Bootstrap bias: ", formatC(x$boot_bias, digits = 6, format = "f"), "\n", sep = "")
  invisible(x)
}

Try the jsdtools package in your browser

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

jsdtools documentation built on March 31, 2026, 1:06 a.m.