Understanding Structured Data Types
Understanding Structured Data Types
Structured data refers to data that is organized and formatted in a specific way to make it
easily readable and understandable by both humans and machines. It has well-defined
structure and it follows a consistent order and can be easily accessed and used by a
person or a computer program.
Structured Data
Structured data
Numerical Data
Numeric data Categorical Data
Continuous
Lorem Ipsum Discrete
Lorem Ipsum Binary Data Ordinal Data
Nominal Data
● Nominal Data: Data with no inherent order or ranking such as gender or
race.
● Ordinal Data: Data with an ordered series of information is called ordinal
data.
● Binary Data: A special case of categorical data with just two categories of
values, e.g., 0/1, true/false.
● Numeric: Data that are expressed on a numeric scale.
● Continuous: Data that can take on any value in an interval. (Synonyms:
interval, float, numeric)
● Discrete: Data that can take on only integer values, such as counts.
(Synonyms: integer, count)
● Categorical: Data that can take on only a specific set of values
representing a set of possible categories. (Synonyms: enums, enumerated,
factors, nominal)
Binary Data
● Binary data can have only two values. If you can place an observation
into only two categories, you have a binary variable.
● Binary variables are helpful for calculating proportions or percentages,
such as the proportion of defective products in a sample.
Trimmed mean
The average of all values after dropping a fixed number of extreme values.
Suppose that a marketing firm conducts a survey of 1,000 households to
determine the average number of TVs each household owns. The data show a
large number of households with two or three TVs and a smaller number with
one or four. Every household in the sample has at least one TV and no
household has more than four. Find the mean number of TVs per household.
Mean = 2.566
1. Consider a dataset of 20 values: [2, 4, 6, 8, 10, 12, 14, 16,
18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]. Calculate a
10% trimmed mean.
Median
● The median is the middle number on a sorted list of the data.
● If there is an even number of data values, the middle value is
one that is not actually in the data set, but rather the average of
the two values that divide the sorted data into upper and lower
halves.
● The sorting of the data can be done either in ascending order or
descending order. A median divides the data into two halves.
Example:
●Median salary of five friends, where the individual salary of each friend is, 74,000,
82,000, 75,000, 96,000, and 88,000. First arranged in ascending order 74,000, 75,000,
82,000, 88,000, and 96,000 then by observing the data we get the median salary as 82,000.
●Median Age of a Group: Consider a group of people ages 25, 30, 27, 22, 35, and 40. First,
arrange the ages in ascending order: 22, 25, 27, 30, 35, 40. The median age is the middle
value, which is 30 in this case.
●Median Test Scores: In a class, the test scores of 10 students are 78, 85, 90, 72, 91, 68,
80, 95, 87, and 81. Arrange them in ascending order: 68, 72, 78, 80, 81, 85, 87, 90, 91, and
95. Since there are an even number of scores, the median is the average of the two middle
values, which are 81 and 85. The median test score is (81 + 85) / 2 = 83.
Median Formula (When n is Odd)
If the number of values (n value) in the data set is odd then the formula to calculate the median is,
Median Formula (When n is Even)
If the number of values (n value) in the data set is even then the formula to calculate the median is:
Median of Grouped Data
Grouped data is the data where the class interval frequency and cumulative frequency of the
data are given. The median of the grouped data median is calculated using the formula,
Median = l + [(n/2 – cf) / f]×h
where,
○ l is Lower Limit of Median Class
○ n is Number of Observations
○ f is Frequency of Median Class
○ h is Class Size
○ cf is Cumulative Frequency of Class Preceding Median Class
Example: Find the Median of the following data, If the marks scored by the students in a class test out
of 50 are,
Example: Find the Median of the following data, If the marks scored by the students in a class test out
of 50 are,
Ans:46.6667
Weighted Median:
Consider a weighted median value ‘wi’ when the elements are sorted such that the total
weight of the elements to the left of wi is half of the total weight. Or else such element will
be chosen as pivot whose total weights on left and right side will be of the least difference
possible after crossing the cumulative sum value of 50% of total.
It can be seen from the table that the weighted median element is 4 because at the weight
corresponding to element 4, the total cumulative sum passes 50%.
Mode
● Mode is the most frequently occurring value in a given set of data.
● For example, if a set of numbers had the digits 1,2,2,3,3,3,4,4,5 then the mode would be 3.
To find the mode, we need to identify the class interval with Using these values in the formula
the highest frequency. In this case, the class interval with the
Mode = l + [(f1 – f0) / (2f1 – f0 – f2)]×h
highest frequency is 30-40, which has a frequency of 12.
⇒ Mode = 30 + [(12 – 8)/(2×12 – 8 – 9)] × 10
Modal class is 30-40
Lower limit of the modal class (l) = 30 ⇒ Mode = 30 + (4/7) × 10
Size of the class interval (h) = 10 ⇒ Mode = 30 +40/7
Frequency of the modal class (f1) = 12
⇒ Mode ≈ 30 + 5.71 = 35.71
Frequency of the class preceding the modal class (f0) = 8
So, the mode for this set of data is approximately 35.71.
Frequency of the class succeeding the modal class (f2)= 9
Other Measures of Location
1. Quartiles: When the measurements are arranged in increasing order, they divide the set of
measurements into equal parts,
a. The first quartile Q1 containing 25% of the measurement
b. The second quartile Q2 containing 50% of the measurement
c. The third quartile Q3 contains 75% of the measurement
1. Decile: The first decile D1 contain 10% of the measurement. D2 contain 20% of the
measurement and so on.
Q2 = [(n+1)/2]th item
Q3 = [3(n+1)/4]th item
Find the Q1, Q2, and Q3 of the given dataset: 3, 5, 7, 8, 10,
11, 3, 1, 11.
We will arrange the data in ascending order: 1, 3, 3, 5, 7, 8, 10, 11, 11
Cut the list into Quarters: (n = number of terms)
● Quartile 1 (Q1) = [(n + 1)/4] th Term = [( 9+ 1) / 4] = 2.25 term
[Rounds off to 3 term] = 3
● Quartile 2 (Q2) = [(n + 1)/2 ] th Term = [{9 + 1)/2] = 5 th Term = 7
● Quartile 3 (Q3) = [3(n + 1)/4 ] th Term = [3 (10 + 1)/4] th Term =
7.5 th Term [Rounds off to 8 th Term] = 11
Imagine you conducted a small study on language development in children
1–6 years old. You’re writing a paper about the study and you want to report
the quartiles of the children’s ages.
Step 1: Count the number of observations in the dataset, Step 4: Find the second quartile
n = 2 + 3 + 4 + 1 + 2 + 2 = 14 n * (2 / 4) = 14 * (2 / 4) = 7
7 is an integer, so Q2 is the mean of the numbers at
Step 2: Sort the observations in increasing order :1, 1,
positions 7 and 8.
2, 2, 2, 3, 3, 3, 3, 4, 5, 5, 6, 6 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 5, 5, 6, 6
Step 3: Find the first quartile Q2 = (3 + 3) / 2
n * (1 / 4) = 14 * (1 / 4) = 3.5 Q2 = 3 years
3.5 is not an integer, so Q1 is the number at Step 5: Find the third quartile
n * (3 / 4) = 14 * (3 / 4) = 10.5
position 4.
10.5 is not an integer, so Q3 is the number at
1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 5, 5, 6, 6 position 11.
Q1 = 2 years 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 5, 5, 6, 6
Q3 = 5 years
Calculate Deciles-3 from the following data 10,50,30,20,10,20,70,30.
Calculate Deciles-7 from the following data
85,96,76,108,85,80,100,85,70,95
Ans: 95.7
Percentile
The distribution of fortnightly wages of 280 employees of an undertaking is given below.
Find the Q1, Q2 and Q3,D4,P66,P10,P90.
Fortnightly wages (Rs.) Frequency Fortnightly wages (Rs.) Frequency Cumulative Frequency
Less than 200 12
Less than 200 12 12
200-400 16
200-400 16 28
400-600 38
400-600 38 66
600-800 78
600-800 78 144
800-1000 80
800-1000 80 224
1000-1200 35
1000-1200 35 259
1200-1400 14
Above 1400 7 1200-1400 14 273
III. P66:-
280x(66/100)=184th Observation
P66 = 800+200/80(184.8-144)
= 902 Rs.
Robust Estimates
● Robustness:
○ Irrespective of the variability in the input, the output variability should be minimal or it should
be within the limits that is prescribed.
○ without changing the cause of variation, you minimize the variation in the output.
○ The ability of Statistical procedures to handle variety of distributions including outliers.
○ Robust statistics is defined as measures on which the extreme observations have little effect.
○ The median is referred to as a robust estimate of location since it is not influenced by outliers
(extreme cases) that could skew the results.
II. The influence function: it is the measure of dependence of the estimator on the value of any
one of the points in the sample.
III. Sensitivity Curve: instead of relying on the data, we can use the distribution of the random
variable.
Estimates of Variability
Location is just one dimension in summarizing a feature. A
second dimension, variability, also referred to as dispersion,
measures whether the data values are tightly clustered or
spread out.
Standard Deviation and Related Estimates
● The most widely used estimates of variation are based on the differences, or deviations,
between the estimate of location and the observed data.
● For a set of data {1, 4, 4}, the mean is 3 and the median is 4. The deviations from the mean
are the differences: 1 – 3 = –2, 4 – 3 = 1, 4 – 3 = 1. These deviations tell us how dispersed the
data is around the central value.
● One way to measure variability is to estimate a typical value for these deviations.
● A simple approach is to take the average of the absolute values of the deviations from the
mean.
● In the preceding example, the absolute value of the deviations is {2 1 1}, and their average is
(2 + 1 + 1) / 3 = 1.33. This is known as the mean absolute deviation and is computed with
the formula:
● The best-known estimates of variability are the variance and the standard deviation which are
based on squared deviations.
● The variance is an average of the squared deviations, and the standard deviation is the square
root of the variance:
● A robust estimate of variability is the median absolute deviation from the median or MAD
● Like the median, the MAD is not influenced by extreme values.
Estimates Based on Percentiles
● A different approach to estimating dispersion is based on looking at the spread of the
sorted data.
● Statistics based on sorted (ranked) data are referred to as order statistics
● The most basic measure is the range: the difference between the largest and smallest
numbers.
● A common measurement of variability is the difference between the 25th percentile and
the 75th percentile, called the interquartile range (or IQR). Here is a simple example:
{3,1,5,3,6,7,2,9}. We sort these to get {1,2,3,3,5,6,7,9}. The 25th percentile is at 2.5, and
the 75th percentile is at 6.5, so the interquartile range is 6.5 – 2.5 = 4.
Suppose the test score where 22,34,68,75,79,79,81,83,84,87,90,92,96 and 99. If
your score was 75, in what percentile did you score?
Solution:
There were 14 scores reported and there were 4 scores at or below yours
(4/14) x 100%=29.
● Draw a rectangular box whose bottom is the lower quartile (i.e 25th percentile) and
whose top is the upper quartile (75th percentile)
● Draw a horizontal line segment inside the box to represent the median
● Extend horizontal line segments from each end of the box out to most extreme
observation
Find Q1, Q2 and Q3 for the following data set and draw a boxplot.{2,6,7,8,8,11,12,13,14,15,22,23}
Solution:
There are 12 data points arranged. The middle two are 11 and 12 so the median i.e Q2=11.5
The lower half of the data set is {2,6,7,8,8,11}. The median of this lower half is 7.5 i.e Q1=7.5
The upper half of the data set is {12,13,14,15,22,23}. The median of this upper half is 14.5 i.e Q3=
14.5
Outliers
● An outlier is any value that is very distant from the other values in a data set.
● outliers are often the result of data errors such as mixing data of different units (kilometers
versus meters) or bad readings from a sensor.
● When outliers are the result of bad data, the mean will result in a poor estimate of location,
while the median will still be valid.
● Example:
{5,40,42,46,48,49,50,50,52,53,55,56,58,75,102}
Q1 - (1.5 x I Q R)
Solution:
=46-(1.5 x 10)
There are totally 15 values, hence
=46-15
Q2= 50
=31
Q1 is the 4th data point, i.e Q1= 46
Q3 + (1.5 x I Q R)
Q3 is the 12th data point, i.e Q3=56
=56 + (1.5 x 10)
I Q R= Q3-Q1
=56 + 15
= 56-46
= 71
= 10
Frequency Tables and Histograms
A frequency table of a variable divides up the variable range into equally spaced segments and tells us how many values fall
within each segment
Cumulative frequency(more than) Table Cumulative frequency(less than) Table
Class Frequency Cumulative Class Frequency Cumulative
Interval Frequency Interval Frequency
145-146 2 2 145-146 2 50
147-148 5 7 147-148 5 48
149-150 8 15 149-150 8 43
151-152 15 30 151-152 15 35
153-154 9 39 153-154 9 20
155-156 6 45 155-156 6 11
157-158 4 49 157-158 4 5
159-160 1 50 159-160 1 1
Total 50 Total 50
Histogram
● A histogram is a way to visualize a frequency table, with bins on the x-axis and the data count on the
y-axis.
● Commonly used device for charting continuous frequency distribution
Construction of Histogram
Histogram with equal classes: Histogram with unequal classes:
● If classes are of equal magnitude each class ● If the classes are not uniform, then the
interval is drawn on X-axis by a section which different classes are represented on x-axis by
is equal to the magnitude of the class interval sections which are equal to the magnitude of
● On each class interval insert a rectangle with corresponding classes and the heights of the
corresponding rectangles are to be adjusted
the height proportional to the corresponding
so that the area of the rectangle is equal to
frequency of the class
the frequency of the corresponding class.
● The series of adjacent rectangles so formed ● This can be done by taking the height of each
gives the histogram of the frequency rectangle equal to the corresponding
distribution and its area represent the total frequency density of each class, where
frequency of the distribution
Frequency density of a class= Frequency of a class
The degree represented by the various component parts of a given magnitude can be obtained as
follow:
Total Value
● It is very useful for data scientists to know and understand the chances of
an event occurring and can be very effective in the decision-making
process.