
Last chance! 50% off unlimited learning
Sale ends in
Median absolute deviation, adapted to operate on complex data as well as numeric.
In the later case it simply calls stats::mad()
.
For complex x it uses the geometric median, pracma::geo_median()
, as the center,
then returns the median absolute difference between center and each element of x, multiplied by constant
.
mad(
x,
center = median(x),
constant = 1.4826,
na.rm = FALSE,
low = FALSE,
high = FALSE
)
numeric. The median absolute deviation (MAD) from center.
a numeric or complex vector.
optional, numeric or complex. The center about which to calculate MAD. Defaults to median for numeric, and geo_median for complex.
a constant by which to multiply the median absolute deviation from center. Default is 1.4826, which is the inverse of the 3/4 quantile for the normal distribution.
logical. Should NAs be removed from x before calculating.
logical. If TRUE, compute the "lo-median", i.e., for even sample size, do not average the two middle values, but take the smaller one. Not used if x is complex.
logical. If TRUE, compute the "hi-median", i.e., take the larger of the two middle values for even sample size. Not used if x is complex.
median.complex, stats::mad
set.seed(4242)
n <- 8
foo <- complex(real = rnorm(n), imaginary = rnorm(n))
mad(foo)
Run the code above in your browser using DataLab