R/CalculateSkew.R

Defines functions CalculateSkew

Documented in CalculateSkew

CalculateSkew <-
function(x) {
  # 
  # Computes the sample skewness of a distribution.
  #
  # Args:
  #   x: Data (vector).
  #
  # Returns:
  #   The sample skewness of x (scalar).
  # 
  n <- length(x)
  m1 <- mean(x)
  m2 <- sum((x - m1) ^ 2) / n
  m3 <- sum((x - m1) ^ 3) / n
  g1 <- m3 / (m2 ^ (3/2))
  g1 <- (sqrt(n * (n - 1)) / (n - 2)) * g1
  return(g1)
}

Try the RTaxometrics package in your browser

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

RTaxometrics documentation built on Sept. 10, 2017, 1:03 a.m.