Department of Mathematics
Dr. Hossam M. Hassan
Probability and Statistics
Worksheet No. (2) - Solution
Section 1: Data Description
Problem 1:
The Big Mac index was created by The Economist in 1986 as a lighthearted guide to whether
currencies are at their “correct” level. The data, which contains the dollar price (rounded to 2
decimal places) of a Big Mac burger in 56 countries as of July 2018, is shown in the following
histogram.
a. What conclusions can you reach about the differences in prices among the countries?
b. What is the relation between different measures of central tendency for this data?
Solution:
a. There is a $4.79 difference in the dollar price of a Big Mac between the lowest and the
highest prices. The price distribution is right-skewed, with one country reporting a price
over $6. Most countries charge between $2 and $5.
b. Since the data skewed to the right, the 𝐦𝐨𝐝𝐞 < 𝐦𝐞𝐝𝐢𝐚𝐧 < 𝐦𝐞𝐚𝐧.
Page 1 of 15
Problem 2:
Find the mean, standard deviation, and coefficient of variation for samples with the following
statistics.
𝑛 𝑛
𝑛 = 10, ∑ 𝑥𝑖2 = 1325, ∑ 𝑥𝑖 = 97
𝑖=1 𝑖=1
Solution:
𝑛
1 97
𝑋̅ = ∑ 𝑥𝑖 = = 𝟗. 𝟕
𝑛 10
𝑖=1
𝑛 ∑𝑛𝑖=1 𝑥𝑖2 − (∑𝑛𝑖=1 𝑥𝑖 )2 10 (1325) − (97)2
2
𝑠 = = = 42.68
𝑛(𝑛 − 1) 10 (9)
𝑠 = √𝑠 2 = √42.68 = 𝟔. 𝟓𝟑
𝑆 6.53
𝐶𝑉𝑎𝑟 = × 100% = × 100% = 𝟔𝟕. 𝟑𝟒%
𝑋̅ 9.7
Section 2: Measures of Position
Problem 3:
The following data represents the grades of 20 computer science students on a math test. Find
the mean, mode, median, range, variance, and standard deviation of these grades.
87, 86, 85, 87, 86, 87, 85, 81, 76, 85, 84, 85, 83, 82, 80, 79, 80, 74, 78, 90
Solution:
𝑛 = 20
𝑛
1 1
Mean = 𝑥̅ = ∑ 𝑥𝑖 = (1660) = 𝟖𝟑
𝑛 20
𝑖=1
Mode = 𝟖𝟓 (appeared 4 times)
Page 2 of 15
The sorted data is:
74, 76, 78, 79, 80, 80, 81, 82, 83, 84, 85, 85, 85, 85, 86, 86, 87, 87, 87, 90
𝑥10 + 𝑥11 84 + 85
Median = = = 𝟖𝟒. 𝟓
2 2
Range = 90 − 74 = 𝟏𝟔
Variance = 𝑆 2 = 17.16 → Standard deviation = 𝑆 = √17.16 = 𝟒. 𝟏𝟒
Section 3: Concept Check
Problem 4:
State whether each statement is True or False and justify your answer.
1. In the construction of a frequency distribution, it is a good idea to have overlapping class
limits, such as 10–20, 20–30, 30–40.
False, Class limits must be mutually exclusive. If classes overlap (e.g., 20 is in both 10-20
and 20-30), you wouldn't know which group to put the value "20" into.
2. Histograms can be drawn by using vertical or horizontal bars.
False, while bar charts for categorical data can be horizontal, a Histogram uses vertical
bars.
3. It is not important to keep the width of each class the same in a frequency distribution.
False, if class widths are unequal, the height of the bars becomes misleading (a wider class
might look "taller" just because it covers more numbers, not because the density is higher).
4. Frequency distributions can aid the researcher in drawing charts and graphs.
True, organizing raw data into a frequency table is the necessary first step before creating
visualizations such as histograms, polygons, or Pareto charts.
Page 3 of 15
5. The type of graph used to represent data is determined by the type of data collected and by
the researcher’s purpose.
True, Different data requires different tools. For example, Categorical data needs Bar/Pie
charts, while Numerical (Time) data needs Time graphs.
6. In the construction of a frequency polygon, the class limits are used for the x-axis.
False, Frequency polygons use the Class Midpoints on the x-axis, not the limits.
7. Data collected over a period of time can be graphed by using a pie graph.
False, Time-series data should be graphed using a time-series graph. A Pie chart shows
parts of a whole at a single point in time, not changes over time.
8. When the mean is computed for individual data, all values in the data set are used.
∑𝑥
True, the formula for the mean (𝑥̅ = ) requires summing every single value.
𝑛
9. The mean cannot be found for grouped data when there is an open class.
True, an "open class" (like "Age > 65") has no defined upper limit. Without a limit, you
cannot calculate the Mean.
10.A single, extremely large value can affect the median more than the mean.
False, it is the opposite. The Mean (Average) uses every single number in its formula. If
one number changes drastically, the total sum changes drastically, which pulls the Mean
toward that number. The Median only cares about the order (position); it is the middle
value. The median is resistant to extreme values.
[Link]-half of all the data values will fall above the mode, and one-half will fall below the
mode.
False, this is the definition of the Median. The Mode is simply the most frequent value.
[Link] a data set, the mode will always be unique.
False, a dataset can have no mode, one mode (unimodal), or multiple modes
(bimodal/multimodal).
Page 4 of 15
[Link] disadvantage of the median is that it is not unique.
False, the median is always unique. If there are two middle numbers, we average them to
produce a single, unique result.
[Link] mean can be a negative value.
True, if the data consists of negative numbers, the average will mathematically be
negative.
[Link] variance can be a negative value.
False, variance is calculated by squaring the deviations ((𝑥 − 𝑥̅ )2 ). Since squared numbers
are always positive, the variance can never be negative.
Section 4: Case Study
Problem 5:
A Database Administrator (DBA) is testing the performance of a new SQL query on a
production server. The goal is to ensure consistent performance. The DBA records the
Execution Time (in milliseconds) for 24 random query runs:
42, 45, 40, 38, 120, 41, 39, 43, 44, 115, 40, 42
39, 41, 37, 130, 43, 45, 40, 41, 36, 42, 44, 38
a. Construct a Frequency Distribution Table for the data using 5 classes.
b. Draw a Histogram to show the shape of the data. Is it symmetric or skewed?
c. Calculate the Mean, Mode, and Median. Which metric accurately represents the "typical"
query time?
d. The Service Level Agreement (SLA) states that "Queries must not exceed 100ms." Based
on your analysis, is the new query stable enough for production?
Page 5 of 15
Solution:
a.
Range = 130 − 36 = 94
Class width = 94/5 = 18.8 ≅ 20
Class (Interval) Limits Frequency (f)
30 − 50 21
50 − 70 0
70 − 90 0
90 − 110 0
110 − 130 3
b.
Histogram
The histogram is Heavily Skewed to the Right (Positively Skewed). Most data are
clustered between 30-50ms, but a small group is far to the right (>110ms).
c. Mean: 51.7ms
Mode: 40,41, and 42ms (Multimodal)
Median: 41.5ms
Analysis: The Mean is misleadingly high. The Median confirms that most queries are
actually very fast (41.5ms).
Page 6 of 15
Problem 6:
A first-year Computer Science student records the number of Syntax Errors found by the compiler
in 8 different coding assignments:
14, 6, 3, 10, 1, 8, 4, 7
a) Calculate the mean, median, and mode.
b) Calculate the range, variance, standard deviation, and coefficient of variation.
c) Find the five-number summary and P80.
d) Calculate the Z score for all values.
e) Describe the shape for the given set of data.
Solution:
a)
𝑛
1 53
𝑋̅ = ∑ 𝑥𝑖 = = 𝟔. 𝟔𝟐𝟓
𝑛 8
𝑖=1
Median: the ordered numbers are
1, 3, 4, 6, 7, 8, 10, 14
𝑛𝑝 8×50
The location of the median 𝑐 = = = 4, since 𝑐 is a whole number, therefore
100 100
4𝑡ℎ 𝑣𝑎𝑙𝑢𝑒 + 5𝑡ℎ 𝑣𝑎𝑙𝑢𝑒 6 + 7
𝑀𝐷 = = = 𝟔. 𝟓
2 2
There is no mode for the data, since all values are repeated the same number of times.
b)
Range = Max − Min = 14 − 1 = 𝟏𝟑
1 1
Variance: 𝑠 2 = ∑(𝑥 − 𝑋̅)2 = [(1 − 6.625)2 + (3 − 6.625)2 + ⋯ +
𝑛−1 7
(14 − 6.625)2 ] = 𝟏𝟕. 𝟏𝟐𝟓
Standard deviation: 𝑠 = √𝑠 2 = √17.125 = 𝟒. 𝟏𝟑𝟖
Page 7 of 15
𝑠 4.138
Coefficient of variation: 𝐶𝑣𝑎𝑟 = × 100 = × 100 = 𝟔𝟐. 𝟒𝟔𝟒
𝑋̅ 6.625
c) Minimum: min. = 𝟏 Maximum: max. = 𝟏𝟒
𝑛𝑝 8(25) 3+4
1st quartile: 𝑐 = = = 2, therefore 𝑄1 = = 𝟑. 𝟓
100 100 2
Median: 𝑀𝐷 = 𝟔. 𝟓
𝑛𝑝 8(75) 8+10
3rd quartile: 𝑐 = = = 6, therefore 𝑄3 = =𝟗
100 100 2
𝑛𝑝 8(80)
𝑃80 : 𝑐 = = = 6.4, therefore it the 7th value, 𝑃80 = 𝟏𝟎
100 100
𝒙 − 𝟔. 𝟔𝟐𝟓
𝑥 − 𝑋̅ 𝒙 𝒁=
d) Z − score ⇨ 𝑧 = . (Hint: It is not a must to calculate 𝟒. 𝟏𝟑𝟖
𝑠
the z-score for the sorted data) 1 -1.359
3 -0.876
It seems from the table that there are no outliers, since
all z-scores are within the usual range of -2 to 2. 4 -0.634
6 -0.151
e) It seems from the box plot of the data that the data is
slightly skewed to the right, which is also seen from 7 0.091
the values of the mean and median, since 𝑚𝑒𝑎𝑛 >
8 0.332
𝑚𝑒𝑑𝑖𝑎𝑛.
10 0.816
14 1.782
Page 8 of 15
Problem 7:
The data given contains the average room price (in US$) paid by various nationalities while
traveling abroad (away from their home country) in 2016:
124, 101, 115, 126, 114, 112, 138, 85, 138, 96, 130, 116, 132
a) Compute the mean, median, and mode.
b) Compute the range, variance, and standard deviation.
c) Based on the results of (a) and (b), what conclusions can you reach concerning the room
price (in USD) paid by international travelers while traveling to various countries in 2016?
d) Suppose that the last value was 175 instead of 132. Repeat (a) through (c), using this value.
Comment on the difference in the results.
Solution:
a)
Required USD $
Mean 𝑋̅ 117.462
Median 𝑋̃ 116
Mode 138
b)
Required USD $
Range 𝑹 53
Variance 𝑆 2 263.603
Standard Deviation 𝑆 16.235
Page 9 of 15
c) The mean room price is $117.4615, and half the room prices are greater than or equal to
$116, so the room price is slightly right-skewed. The average scatter around the mean is
16.2358. The lowest room rate is $85 in Mexico, and the highest is $138 in Japan.
d) The mean increases to 120.7692, while the median and the mode remain the same. The
data is now slightly more right-skewed. The average scatter around the mean increases to
22.5876. The range is now 90.
Problem 8:
A Lead Developer is assessing the quality of a legacy codebase before a major refactor. She
measures the Cyclomatic Complexity (a metric indicating the number of independent paths
through the code) for 28 critical functions. Note: A complexity score above 50 is considered
"unstable and untestable".
Data (Complexity Score):
23, 27, 26, 25, 40, 19, 26, 36, 23, 33, 23, 11, 38, 21,
26, 23, 21, 33, 40, 15, 55, 30, 41, 31, 47, 37, 33, 28
c. Compute the first quartile (Q1), the third quartile (Q3), and the interquartile range. (List
the five-number summary)
d. Construct a boxplot and describe its shape.
e. Study if there are any outliers in the data. Does any function exceed the "untestable"
threshold?
Solution:
c. Minimum = 11, 𝑄1 = 𝟐𝟑, Median = 27.5, 𝑄3 = 𝟑𝟕, Maximum = 55.
Interquartile Range 𝐼𝑄𝑅 = 𝑄3 − 𝑄1 = 𝟏𝟒 .
Page 10 of 15
d.
The boxplot is right-skewed
e. Lower boundary = 𝑄1 − 1.5 × 𝐼𝑄𝑅 = 23 − 1.5 × 14 = 𝟐
Upper boundary = 𝑄3 + 1.5 × 𝐼𝑄𝑅 = 37 + 1.5 × 14 = 𝟓𝟖
There are no outliers in the data, as no values fall below the lower boundary or exceed
the upper boundary. While the value 55 is not a statistical anomaly, it is a critical
engineering risk. One function exceeds the safety threshold and requires immediate
refactoring.
Problem 9:
A global logistics company is analyzing the delivery time (in days) for standard international
shipping packages. The distribution of delivery days is summarized in the Box Plot below.
Page 11 of 15
a. Identify the Five-Number Summary (Min, Q1, Median, Q3, Max).
b. Calculate the Interquartile Range (IQR).
c. Calculate the Lower and Upper Fences to determine the cutoff values for outliers.
d. The company policy states that any delivery taking longer than the Upper Fence is
considered a "Service Failure" and requires a full refund to the customer. Based on the
plot, were there any Service Failures in this batch? Explain.
Solution:
a. Minimum = 2, 𝑄1 = 𝟒, Median = 6, 𝑄3 = 𝟗, Maximum = 20.
b. Interquartile Range 𝐼𝑄𝑅 = 𝑄3 − 𝑄1 = 𝟓 .
c. Lower boundary = 𝑄1 − 1.5 × 𝐼𝑄𝑅 = 4 − 1.5 × 5 = −𝟑. 𝟓
Upper boundary = 𝑄3 + 1.5 × 𝐼𝑄𝑅 = 9 + 1.5 × 5 = 𝟏𝟔. 𝟓
d. ∵ there is a number (20) exceeded the upper boundary
∴ there was a Service Failure in this batch, and the company owes refunds for this specific
package (the outlier).
Problem 10:
A Data Scientist is analyzing three different datasets from a tech company. Below are three
Histograms and three Box Plots. Match each Histogram to its corresponding Box Plot.
H1 H2 H3
Page 12 of 15
B1 B2 B3
Solution:
H1 H2 H3
B2 B3 B1
Problem 11:
You are the System Architect for a high-frequency trading platform. You are evaluating two
different Cloud Providers (Provider A and Provider B) to host your database. The benchmark
results for Query Response Time follow a Bell-Shaped (Normal) Distribution for both providers.
The Benchmark Results:
• Provider A: Mean = 45 ms, Standard Deviation = 25 ms
• Provider B: Mean = 55 ms, Standard Deviation = 5 ms
a) Which provider is faster on average?
b) Calculate the Coefficient of Variation (CV) for both providers. Which provider is more
consistent/stable?
c) Your Service Level Agreement (SLA) requires that 99% of all queries must finish within
70ms. Based on the data, which provider is risky?
Page 13 of 15
Solution:
a) Provider A is faster on average (lower latency).
b)
25
𝐶𝑣𝑎𝑟𝐴 = × 100 = 𝟓𝟓. 𝟔%
45
5
𝐶𝑣𝑎𝑟𝐵 = × 100 = 𝟗. 𝟏%
55
Provider B is much more consistent/stable because it has a significantly lower Coefficient
of Variation (9.1% vs 55.6%).
c) Since the data is normally distributed, we will use the Empirical Rule.
Provider A:
• Mean = 45ms.
• 70ms is exactly 1 standard deviation away from the mean.
• This means nearly 𝟔𝟖% of requests will fall within ±1 standard deviations. This
violates the 99% success requirement.
Provider B:
• Mean = 55ms.
• 70ms is exactly 3 Standard Deviations away from the mean.
• This means nearly 𝟗𝟗. 𝟕% of requests will fall within ±3 standard deviations.
Provider B will almost never breach the limit.
Although Provider A is faster on average, it is too unstable. Provider B guarantees that
you meet the Service Level Agreement (SLA) reliability target, whereas Provider A poses
a high risk of failure.
Page 14 of 15
Problem 12:
A Cyber-Security system monitors two different metrics for a web server. At 9:00 AM, it triggers
two alerts simultaneously. You must decide which anomaly is more statistically significant.
• Metric 1 (CPU Temperature):
▪ Current Reading: 85∘ 𝐶
▪ Historical Normal: Mean = 65∘ 𝐶, Standard Deviation = 8∘ 𝐶
• Metric 2 (Memory Usage):
▪ Current Reading: 14 𝐺𝐵
▪ Historical Normal: Mean = 8 𝐺𝐵, Standard Deviation = 1.5 𝐺𝐵
Determine which of these two alerts is more critical. Explain your reasoning.
Solution:
We need to compare two different units (Degrees vs. Gigabytes). We cannot compare the raw
numbers (85 vs 14). We must standardize them using Z-scores.
𝑥 − 𝑋̅ 85 − 65 14 − 8
𝑍𝑡𝑒𝑚𝑝 = = = 𝟐. 𝟓, 𝑍𝑚𝑒𝑚𝑜𝑟𝑦 = = 𝟒
𝑠 8 1.5
Memory Usage is the more extreme (4 > 2.5). Even though the raw number for memory (14)
looks smaller than the temperature (85).
Page 15 of 15