R/dlaplace.R

Defines functions dlaplace

Documented in dlaplace

dlaplace <-
function(x, mean=0, sd=1) {
  # Laplace (double exponential) density function with mean equal to \code{mean} and standard deviation equal to \code{sd}. 
  # 'x': Vector of quantiles.
  # 'mean': Population mean.
  # 'sd': Population standard deviation.
  # example:    dlaplace( seq( 20, 80, length.out=11 ), 50, 10 )
  if (!is.numeric(x))  stop("'x' must be numeric.")
  if (!is.numeric(mean))  stop("'mean' must be numeric.")
  if (!is.numeric(sd))  stop("'sd' must be numeric.")
  if (sd<0)  stop("'sd' cannot be negative.")
  if (sd==0)  return( dnorm(x, mean, 0) )
  exp(-abs(x-mean)*sqrt(2)/sd)/(sd*sqrt(2))
}

Try the jmuOutlier package in your browser

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

jmuOutlier documentation built on Aug. 6, 2019, 1:03 a.m.