R/sample_mode.R

Defines functions sample_mode

Documented in sample_mode

#' Sample Mode
#' 
#' Calculate the sample mode of vector x.
#'
#' @param x vector of sample data 
#'
#' @return sample mode 
#' @export
#' @importFrom stats density
#'
#' @examples sample_mode(rbeta(100, 2, 7))
sample_mode <- function(x){
  d <- density(x)
  d$x[which.max(d$y)]  
}

Try the bayesrules package in your browser

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

bayesrules documentation built on Sept. 25, 2021, 9:06 a.m.