Skip to content

Instantly share code, notes, and snippets.

@timothyslau
Last active August 29, 2015 14:28
Show Gist options
  • Save timothyslau/707f035198c6b204b1c4 to your computer and use it in GitHub Desktop.
Save timothyslau/707f035198c6b204b1c4 to your computer and use it in GitHub Desktop.
Breakdown Point Demonstration
# Mean v. Median
# Tim's point (break down point of the mean is 0 and median is 0.5)
x0 <- c(1:10)
mean(x0)
median(x0)
x1 <- c(1:9, 1000)
mean(x1)
median(x1)
x2 <- c(1:8, 1000, 10000)
mean(x2)
median(x2)
x3 <- c(1:7, 1000, 10000, 100000)
mean(x3)
median(x3)
x4 <- c(1:6, 1000, 10000, 100000, 1000000)
mean(x4)
median(x4)
x5 <- c(1:5, 1000, 10000, 100000, 1000000, 10000000)
mean(x5) # breaks down
median(x5)
# Jeff's point (breakdown only happens with positive values)
x6 <- c(1:10)
mean(x6)
median(x6)
x7 <- c(1:9, 1000)
mean(x7)
median(x7)
x8 <- c(1:8, 1000, -1000)
mean(x8)
median(x8)
x9 <- c(1:7, 1000, -1000, 100000)
mean(x9)
median(x9)
x10 <- c(1:6, 1000, -1000, 100000, -100000)
mean(x10)
median(x10)
x11 <- c(1:5, 1000, -1000, 100000, -100000, 1000000)
mean(x11)
median(x11)
x12 <- c(1:4, 1000, -1000, 100000, -100000, 1000000, -1000000)
mean(x12)
median(x12)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment