计算 R 编程中的中值绝对偏差 - mad()函数
R 语言中的mad()
函数用于计算中值绝对偏差,即与中值的绝对偏差的 (lo-/hi-) 中值。
Syntax: mad(x)
Parameters:
x: Vector
示例 1:
# R Program to calculate
# Median Absolute Deviation
# Creating a vector
x <- c(1:9)
# Calling mad() Function
mad(x)
输出:
[1] 2.9652
示例 2:
# R Program to calculate
# Median Absolute Deviation
# Creating a vector
x <- c(1, 4, 2, 3, 7, 3, 8, 9, 2)
# Calling mad() Function
mad(x)
输出:
[1] 1.4826