How to measure central tendency in Python and R

Tracyrenee
Geek Culture
Published in
3 min readOct 26, 2022

--

A measure of central tendency is a summary measure that attempts to describe a whole set of data with a single value that represents the middle or centre of its distribution.

There are three statistical measurements that can be used to measure the central tendency, and these measurements are:-

  1. Mean, being the average of a group of numbers.
  2. Median, being the centre number in a group of numbers.
  3. Mode, being the most frequently used number.

Computer technology is great because it enables a researcher to quickly and efficiently calculate the central tendency. In this post I will demonstrate how to measure the central tendency of a list of ages in two different programming languages, being Python and R.

Python is a general purpose language that utilises inbuilt and outsourced open source libraries to help it to make calculations by calling a function.

R is a statistical programming language designed for statisticians. This language has many inbuilt functions, but some of them, such as the mode function, must be imported through libraries.

The first language that I am going to demonstrate the measure of the central tendency is Python. I have written the code in a Jupyter Notebook that is hosted by Google, being Google Colab:-

  1. Python does not have an inbuilt mean function, so a variable must be created, mean_age, which is the sum of…

--

--

Tracyrenee
Geek Culture

I have five decades experience in the world of work, being in fast food, the military, business, non-profits, and the healthcare sector.