Measures of central tendency

What if you had to describe the center of a distribution within a single number? Most people would appeal to one of these three estimators: mean, median, or mode. Those are probably the most popular measures of central tendency. Let's begin by sampling data from an arbitrary distribution. Get into your R console and try the following code:

set.seed(10)small_sample <- rnorm(n = 10, mean = 10, sd = 5)big_sample <- rnorm(n = 10^5, mean = 10, sd = 5)

The first line is setting the seed number to work with our random number generator (RNG). Every time there's a need to rely on a pseudo-random process, the set.seed() function will make sure your code is reproducible (at least at some level). By setting it to 10 you will ...

Get Hands-On Data Science with R now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.