Tutorial 6
Tutorial 6
Problem statement:
1. Find Stem-Leaf plot for the following data and provide the key to
interpret the plot. 8.6, 2.5, 9.5, 7.3, 8.4, 2.1, 9, 2.5, 6.7, 7.1, 2.5, 9.4,
8.2, 2.1, 8.4, 7.5, 2.8, 7.2. 2.2
Ans :
Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Data
data = [8.6, 2.5, 9.5, 7.3, 8.4, 2.1, 9, 2.5, 6.7, 7.1, 2.5, 9.4, 8.2, 2.1, 8.4, 7.5, 2.8, 7.2, 2.2]
Output:
2 | 5155172
6|7
7 | 2052
8 | 5414
Somaiya Vidyavihar University
(Constituent College – K J Somaiya College
of Engineering)
9 | 504
Find Box plot for the following data and provide the key to interpret the plot. 23,
67, 62, 52, 23, 25, 33, 55, 58, 44, 33, 32, 29, 39, 31, 55, 66, 45, 41, 43, 36, 43,
41, 41, 62
Find the minimum, maximum, first quartile, third quartile and median values from the plot.
Box Plot
Start
Import Libraries: Import necessary libraries (NumPy, Matplotlib).
Define Data: Store the dataset in a variable.
Calculate Statistics:
Sort the data.
Compute:
o Minimum
o First Quartile (Q1)
o Median (Q2)
o Third Quartile (Q3)
o Maximum
Create Box Plot: Use Matplotlib to create a box plot.
Display Box Plot: Show the plot.
Print Statistics: Output the calculated statistics.
Interpret Plot: Analyze the box plot.
Somaiya Vidyavihar University
(Constituent College – K J Somaiya College
of Engineering)
Somaiya Vidyavihar University
(Constituent College – K J Somaiya College
of Engineering)
Results Analysis:
Minimum (23): The lowest value in the dataset, shown as the leftmost whisker of
the box plot.
First Quartile (Q1 = 36): This indicates that 25% of the data points are below 36,
represented by the left edge of the box.
Median (Q2 = 41): The middle value of the dataset, where 50% of the data points are
below and 50% are above, indicated by the line inside the box.
Third Quartile (Q3 = 55): This shows that 75% of the data points are below 55,
represented by the right edge of the box.
Maximum (67): The highest value in the dataset, shown as the rightmost whisker of
the box plot.