Median
Yaser Rahmati | یاسر رحمتی
Definition
The median is the middle number in a sorted list of numbers.
If there are an even number of data points, the median is the average of the two middle numbers.
Example 1
Let me walk you through an example in detail.
Step1:
Let’s say we have the following set of numbers:
Step 2:
Sort the numbers in ascending order:
Step 3:
Count the total numbers In this case, we have 7 numbers in the set.
Step 4:
Identify the middle number. Since there are 7 numbers, the middle number is the fourth number, which is 5. So, in this case, the median is 5.
Example 2
If we had an even number of data points, we would take the average of the two middle numbers. For example, if we had the data:
Step 1:
Sort the numbers in ascending order:
Step 2:
Count the total numbers In this case, we have 6 numbers in the set.
Step 3:
Identify the two middle numbers The two middle numbers are 3 and 6. In this case, the median is the average of these two numbers:
So, the median of the given set of numbers is 4.5.
Python
This code calculates the median of the given list of numbers using np.median
from the numpy
library and prints the result.
My Training Video
Keywords
Web Development (Django, Flask)
, Data Science (Pandas, NumPy, Matplotlib)
, Machine Learning (Scikit-learn, TensorFlow, PyTorch)
, Artificial Intelligence
, Automation
, GUI Development (Tkinter, PyQt)
, Game Development (Pygame)
, Scientific Computing
, Financial Analysis (Pandas, NumPy
) , Network Programming
, Image Processing (OpenCV)
, Web Scraping (Beautiful Soup, Scrapy)
, Internet of Things (IoT) Development
, Robotics
, Cybersecurity
, Mobile App Development (Kivy)
, Cloud Computing (Boto3, AWS Lambda)
, Big Data Analysis (PySpark)
, Geographical Information Systems
, Natural Language Processing (NLTK, spaCy)
, Data Visualization (Seaborn, Plotly)
, Bioinformatics (Biopython)
, Multimedia Applications
, Education and Teaching
Last updated