Chapter-1
Chapter-1
Linear Models
Linear models form the foundation of many mathematical and statistical methods used in
engineering, data science, and machine learning. They describe relationships between a dependent
variable (response) and one or more independent variables (predictors) using a linear function.
Despite their simplicity, linear models are powerful tools for prediction, inference, and
interpretation.
A linear model assumes that the dependent variable 𝑦 can be expressed as a linear combination
of input variables 𝑥 1 , 𝑥 2 , . . . , 𝑥 𝑛 and an error term 𝜖:
𝑦 = 𝛽0 + 𝛽1 𝑥 1 + 𝛽2 𝑥 2 + ⋯ + 𝛽𝑛 𝑥 𝑛 + 𝜖
Where:
• The term linear refers to linearity in the parameters 𝛽𝑖 , not necessarily in the variables 𝑥 𝑖.
Page 1 of 57
Polynomial Regression:
Extends linear regression by including polynomial terms of the predictors to model nonlinear
relationships.
Extends linear models to handle non-normal response variables by applying a link function g(⋅):
𝑔(𝔼[𝑌]) = 𝛽0 + 𝛽1 𝑥1 + ⋯ + 𝛽𝑛 𝑥 𝑛
Examples:
Used when data are organized at more than one level (e.g., patients within hospitals), allowing for
both fixed and random effects in the modeling.
The most common method for estimating parameters 𝛽𝑖 is the Least Squares Method, which
minimizes the sum of squared residuals:
Page 2 of 57
𝑛
Where:
• 𝛽= vector of coefficients
After fitting a model, its performance is evaluated using statistical measures such as
• Mean Squared Error (MSE): Average of squared differences between observed and
predicted values.
• Root Mean Squared Error (RMSE): Square root of MSE, in the same units as the
response variable.
• Health Sciences: For understanding the impact of risk factors on health outcomes.
• Engineering fields:
Page 3 of 57
iii. Control Systems: Modeling system behavior with linear approximations.
Advantages
• Fast to compute
Limitations
• Sensitive to outliers
A scale is a device or an object used to measure or quantify any event or another object.
Understanding measurement scales is essential in linear modeling, as the choice of scale affects
the type of statistical analysis that can be conducted and the interpretations that can be made.
Linear models are designed to work with different types of data, and the measurement scales of
the variables in these models significantly influence analytical processes. Here’s a breakdown of
the types of measurement scales and how they relate to linear modeling.
Each measurement scale dictates which statistical tools are valid. For instance, correlation and
regression require interval or ratio data.
Nominal Scale:
Definition: This scale categorizes data without a specific order. Each category is mutually
exclusive and there is no ranking among the categories.
Examples: Gender (male, female), marital status (single, married, divorced), and types of vehicles
(sedan, SUV, truck).
Use in Linear Models: While nominal variables cannot be used directly in traditional linear
regression, they can be included in models using techniques like one-hot encoding or creating
dummy variables. For example, if gender is included in a linear model, it would typically be coded
as 0 and 1(e.g., male = 0, female = 1).
Ordinal Scale:
Definition: This scale ranks data in a specific order but does not quantify the difference between
the ranks. It indicates which items have more or less of a certain characteristic.
Examples: Likert scales (e.g., rating satisfaction from 1 to 5), education level (high school,
bachelor's, master's).
Use in Linear Models: Ordinal data can be included in linear models, but care should be taken
when interpreting coefficients, as the differences between ordinal categories may not be equal.
Transformations or specific modeling techniques, such as ordinal logistic regression, may be more
appropriate in some cases.
Page 5 of 57
Interval Scale:
Definition: This scale has both order and equal intervals between values but lacks a true zero point.
The absence of a true zero means that ratios are not meaningful.
Use in Linear Models: Interval data can be used directly in linear regression models as predictor
or outcome variables. Since distances between values are meaningful, the coefficients of the linear
model can be interpreted in terms of changes in the dependent variable associated with changes in
the independent variable.
Ratio Scale:
Definition: This scale has order, equal intervals, and a meaningful zero point, allowing for the
comparison of absolute magnitudes. Ratios of numbers on a ratio scale are also meaningful.
Use in Linear Models: Ratio data is also used directly in linear regression models. With a true zero,
the interpretation of coefficients is straightforward, allowing for both differences and ratios to be
communicated clearly.
Variable Selection: When building a linear model, it is important to recognize the type of variables
(nominal, ordinal, interval, ratio) and choose predictors that will effectively represent the
relationships being modeled.
Model Specification: Based on the measurement scales of your variables, you may need to choose
how to encode nominal data or whether to treat ordinal data differently.
Interpretation of Results: The way you interpret the coefficients depends on the measurement
scale. For example, coefficients for interval or ratio scales provide information about the change
in the dependent variable for a unit change in the independent variable, while coefficients for
nominal scales represent the difference between groups.
Assumptions: Many linear modeling techniques (e.g., ordinary least squares regression) assume
homoscedasticity, normality of residuals, and linearity. Understanding the measurement scales
helps when checking and validating these assumptions.
Page 6 of 57
3. Measures of Central Tendency
3.1 Mean
1
The arithmetic mean is the most common measure: 𝑋ˉ = 𝑛 ∑𝑛𝑖=1 𝑋𝑖
Example:
4+6+8+10 +12
For resistance values 𝑅 = [4,6,8,10,12]: 𝑅ˉ = =8
5
3.2 Median
3.3 Mode
3.4 Comparison
4. Graphs
In data analysis, visualization is key to understanding the patterns and relationships within the
data. Plotting techniques can help reveal important insights and guide decision making. In this
section, we will explore different types of plots such as univariate, bivariate, and multivariate plots.
Page 7 of 57
4.1 Univariate Plots:
Univariate plots are used to visualize the distribution of a single variable. They are useful for
identifying patterns, outliers, and skewness in the data. Common univariate plots include
histograms, density plots, and box plots.
Univariate plots for categorical data are used to visualize the distribution of a single categorical
variable. They are useful for identifying patterns, frequencies, and proportions in the data.
Common univariate plots for categorical data include bar plots, count plots, and pie charts.
a) Bar Plots:
A bar plot displays the frequency or proportion of each category in a categorical variable. Each bar
represents a category, with the height of the bar representing the frequency or proportion of
observations in that category.
b) Count Plots:
A count plot is a type of bar plot that displays the count of observations in each category. It is
similar to a bar plot, but instead of displaying the frequency or proportion, it displays the actual
count of observations.
Page 8 of 57
c) Pie Charts:
A pie chart displays the proportion of each category in a categorical variable. Each slice of the pie
represents a category, with the angle of the slice representing the proportion of observations in that
category.
Univariate plots for numerical data are used to visualize the distribution of a single numerical
variable. They are useful for identifying patterns, outliers, and skewness in the data. Common
univariate plots for numerical data include histograms, density plots, and box plots.
Page 9 of 57
a) Histograms:
A histogram is a bar chart that displays the frequency of a numerical variable’s values. It is created
by dividing the data into intervals, called bins, and counting the number of observations that fall
within each bin.
b) Density Plots:
A density plot is a smoothed version of a histogram. It uses a kernel density estimation (KDE) to
estimate the probability density function of the data. Density plots are useful for comparing the
distribution of two or more datasets.
Page 10 of 57
c) Box Plots:
A box plot, also known as a whisker plot, displays the distribution of a numerical variable using
five number summaries: the minimum, first quartile, median, third quartile, and maximum. It also
shows any potential outliers.
When two variables are analyzed together, the resulting visualization is called a bivariate graph.
Bivariate plots are used to visualize the relationship between two variables. They are useful for
identifying trends, patterns, and correlations. Common bivariate plots include scatter plots, line
plots, and bar plots.
a) Scatter Plots:
A scatter plot displays the relationship between two continuous variables. Each point on the plot
represents an observation, with the x-axis representing one variable and the y-axis representing the
other.
Page 11 of 57
b) Line Plots:
A line plot displays the relationship between two continuous variables, with one variable
represented on the x-axis and the other on the y-axis. Line plots are useful for showing trends over
time.
c) Bar Plots:
A bar plot displays the relationship between two categorical variables. Each bar represents a
category, with the height of the bar representing the value of the second variable.
Page 12 of 57
d) Bubble Chart:
Similar to a scatter plot, but each point is represented by a bubble. The size of the bubble reflects
a third variable, adding another dimension to the analysis.
e) Contour Plot :
A graph used to show the density of data points in two dimensions. It consists of contour lines
representing levels of equal value, helpful for visualizing the relationship between two continuous
variables.
Page 13 of 57
f) Polygon or Line Area Chart:
A chart that displays trends over time by connecting points with a line and filling the area beneath
the line. It provides insights similar to a line graph but emphasizes the magnitude of change.
5. Covariance:
The changes between the two variables, such that change in one variable is equal to change in
another variable. This is the property of a function of maintaining its form when the variables are
linearly transformed. Covariance is measured in units, which are calculated by multiplying the
units of the two variables.
i. If Cov(X, Y) > 0, variables move in the same direction; if < 0, they move oppositely.
Page 14 of 57
ii. If Cov(X, Y) is greater than zero, then we can say that the covariance for any two variables
is positive and both the variables move in the same direction.
iii. If Cov(X, Y) is less than zero, then we can say that the covariance for any two variables is
negative and both the variables move in the opposite direction.
iv. If Cov(X, Y) is zero, then we can say that there is no relation between two variables.
Example:
X Y
2 5
4 10
6 12
8 20
𝑋ˉ = 5, 𝑌ˉ = 11.75
1
Cov(𝑋, 𝑌) = [(2 − 5)(5 − 11.75) + (4 − 5)(10 − 11.75) + (6 − 5)(12 − 11.75) + (8
3
− 5)(20 − 11.75)]
1
= [20.25 + 1.75 + 0.25 + 24.75] = 15.67
3
A positive covariance indicates X and Y increase together.
6.1 Z-Score:
In statistics and data analysis, the Z-score (also known as the standard score) is a crucial concept
used to describe the position of a data point relative to the mean of a data set. It measures how
many standard deviations a value is from the mean. Z-scores are widely used in data
normalization, hypothesis testing, and probability calculations in engineering, computer science,
and data analytics.
Page 15 of 57
Understanding Z-scores helps engineers and data scientists compare values from different datasets,
detect outliers, and standardize features for machine learning algorithms.
Where:
Z-Score Interpretation
𝑍 =0 The data point is exactly equal to the mean.
𝑍 =1 The data point is one standard deviation above the mean.
𝑍 = −1 The data point is one standard deviation below the mean.
𝑍 > 3or 𝑍 < −3 The data point is considered an outlier.
Z-scores are especially important when working with normally distributed data, where:
Example 1:
• Mean 𝜇 = 70
• Standard deviation 𝜎 = 10
• A student scored 𝑋 = 85
Page 16 of 57
𝑋 − 𝜇 85 − 70 15
𝑍= = = = 1.5
𝜎 10 10
Interpretation:
The student’s score is 1.5 standard deviations above the mean. This means the student performed
better than the majority of students in the class.
Example 2:
In another test, the mean score is 𝜇 = 60, standard deviation 𝜎 = 5, and a student scored 𝑋 = 50.
𝑋 − 𝜇 50 − 60
𝑍= = = −2
𝜎 5
Interpretation:
This student’s score is 2 standard deviations below the mean, which indicates a below-average
performance.
In machine learning and data preprocessing, features are standardized using Z-scores to bring them
to a common scale, improving algorithm performance.
𝑋−𝜇
𝑋normalized =
𝜎
Z-scores help identify outliers in datasets. If ∣ 𝑍 ∣> 3, the data point is typically considered an
outlier.
Used to determine if a process measurement lies within acceptable limits of variation (for example,
Six Sigma process control).
Page 17 of 57
(d) Probability and Hypothesis Testing:
Z-scores are used to compute probabilities from the standard normal distribution and perform
Z-tests to compare sample means.
When we convert raw data into Z-scores, the data follows a Standard Normal Distribution,
which has:
• Mean (𝜇) = 0
This transformation simplifies probability calculations because all normal distributions can be
converted into this standardized form.
Suppose we have exam scores that follow a normal distribution with 𝜇 = 70and 𝜎 = 10. What is
the probability that a student scores less than 80?
Interpretation:
There is an 84.13% chance that a randomly selected student scores less than 80.
Page 18 of 57
6.6 Limitations of Z-Score
The Z-score is a fundamental statistical concept that quantifies how far a data point lies from the
mean in terms of standard deviations. It plays a critical role in data analysis, probability
computation, and machine learning preprocessing. For engineers and computer scientists,
mastering Z-score concepts allows for effective data standardization, anomaly detection, and
interpretation of results within various analytical contexts.
Correlation estimates the depth of the relationship between variables. It is the estimated measure
of covariance and is dimensionless. In other words, the correlation coefficient is a constant value
always and does not have any units.
The Pearson correlation coefficient (r) measures the strength and direction of a linear
relationship:
Cov(𝑋, 𝑌)
𝑟=
𝜎𝑋 𝜎𝑌
• 𝑟 = 1: perfect positive correlation
• 𝑟 = 0: no correlation
Where:
• 𝑟 = correlation between the variables X and Y
Based on the value of correlation coefficient, we can estimate the type of correlation between the
given two variables. Also, the graphical representation of correlation among two variables is given
in the below figure.
Page 19 of 57
6.8 Covariance vs Correlation
Example 1:
Number of observations = 6
Mean of X = 17.67
Mean of Y = 25.5
Page 20 of 57
X 2 8 18 20 28 30
Y 5 12 18 23 45 50
Cov(X, Y) = (⅙) [(2 – 17.67)(5 – 25.5) + (8 – 17.67)(12 – 25.5) + (18 – 17.67)(18 – 25.5) + (20 –
17.67)(23 25.5) + (28 – 17.67)(45 – 25.5) + (30 – 17.67)(50 – 25.5)] = 157.8
Example 2:
Example 3:
A student appeared for two tests. He secured 80 in the first and 75 in the second. The mean and
deviation for the first were 70 and 15 respectively, while for the second it was 64 and 12
respectively. What conclusion can you make on comparing the student's performance for both
exams?
Example 4:
The mean temperature of 60 airports was recorded to be 65 degrees with a standard deviation of 5
degrees. If an airport records a temperature of 68 degrees what percentage of temperatures lie
below this value.
The Ordinary Least Squares (OLS) method is one of the most fundamental techniques in
statistical modeling and regression analysis. It is widely used to estimate the parameters of a linear
regression model, which describes the relationship between one dependent variable and one or
more independent variables.
Page 21 of 57
OLS minimizes the sum of the squared differences (errors) between observed values and the
values predicted by a linear function. It is a cornerstone method in data science, machine learning,
econometrics, and engineering data analysis.
The OLS method assumes that the relationship between the dependent variable 𝑌 and the
independent variables 𝑋1 , 𝑋2 , . . . , 𝑋𝑛 is linear, and can be expressed as:
𝑌 = 𝛽0 + 𝛽1 𝑋1 + 𝛽2 𝑋2 + ⋯ + 𝛽𝑛 𝑋𝑛 + 𝜖
Where:
̂0 , 𝛽
The goal of OLS is to find estimates 𝛽 ̂1 , … , 𝛽
̂𝑛 that minimize the sum of squared residuals
𝑚 𝑚
𝑖 =1 𝑖 =1
𝑌𝑖 = 𝛽0 + 𝛽1 𝑋𝑖 + 𝜖𝑖
𝑆 = ∑(𝑌𝑖 − 𝛽0 − 𝛽1 𝑋𝑖 )2
𝑖=1
To find the minimum, take partial derivatives of 𝑆 with respect to 𝛽0 and 𝛽1 , and set them equal to
zero
∂𝑆
= −2∑(𝑌𝑖 − 𝛽0 − 𝛽1 𝑋𝑖 ) = 0
∂𝛽0
∂𝑆
= −2∑𝑋𝑖 (𝑌𝑖 − 𝛽0 − 𝛽1 𝑋𝑖 ) = 0
∂𝛽1
Page 22 of 57
Solving these two equations gives
𝑌̂ = 𝛽
̂0 + 𝛽
̂1 𝑋
For multiple linear regression with several predictors, the OLS model can be expressed in matrix
form
𝑌 = 𝑋𝛽 + 𝜖
Where:
• 𝛽= (𝑝 + 1) × 1vector of coefficients
• 𝜖= 𝑛 × 1vector of errors
𝛽̂ = (𝑋 𝑇 𝑋)−1 𝑋 𝑇 𝑌
Let’s consider a dataset of hours studied (X) and marks obtained (Y):
Page 23 of 57
Step 1: Compute means
𝑋ˉ = 3, 𝑌ˉ = 4
̂1
Step 2: Compute 𝛽
̂0
Step 3: Compute 𝛽
̂0 = 𝑌ˉ − 𝛽
𝛽 ̂1 𝑋ˉ = 4 − (0.6 × 3) = 2.2
𝑌̂ = 2.2 + 0.6𝑋
Interpretation:
For every additional hour studied, marks increase by 0.6 on average.
Suppose we are modeling CPU performance (Y) based on clock speed (X₁) and RAM size (X₂).
The OLS model would be
𝑌 = 𝛽0 + 𝛽1 𝑋1 + 𝛽2 𝑋2 + 𝜖
𝛽̂ = (𝑋 𝑇 𝑋)−1 𝑋 𝑇 𝑌
Such models help engineers predict system performance or resource utilization using statistical
data.
Page 24 of 57
7.4 Assumptions of OLS
𝑅𝑀𝑆𝐸 = √𝑀𝑆𝐸
The t-test is a statistical test used to determine whether there is a significant difference between
the means of two groups. It is mainly used when the sample size is small (usually 𝑛 < 30) and the
population standard deviation is unknown.
Types of t-tests
1. One-sample t-test – compares the sample mean with a known population mean.
Page 25 of 57
2. Independent two-sample t-test – compares the means of two independent samples.
3. Paired t-test – compares means from the same group at different times or under different
conditions.
𝑋ˉ − 𝜇0
𝑡=
𝑠/√ 𝑛
Where:
• 𝑋ˉ = sample mean
• 𝜇0 = population mean (assumed value)
• 𝑛= sample size
Problem:
An engineer wants to check whether two machines produce bolts of the same average length.
A 10 50.5 0.3
B 10 50.2 0.4
Hypotheses:
𝐻0 : 𝜇𝐴 = 𝜇𝐵 (no difference)
𝐻1 : 𝜇𝐴 ≠ 𝜇𝐵
Calculation:
𝑋ˉ1 − 𝑋ˉ 2
𝑡=
𝑠2 𝑠2
√ 1+ 2
𝑛1 𝑛2
50.5 − 50.2 0.3 0.3
𝑡= = = = 1.90
2 2 √ 0.009 + 0.016 0.158
√0.3 + 0.4
10 10
Page 26 of 57
Decision:
At 5% significance level (𝑡0.05,18 = 2.10), since 1.90 < 2.10,
→ Fail to reject 𝐻0 .
Thus, there is no significant difference between the two machines’ output lengths.
The F-test is used to compare two population variances and to determine if they are significantly
different. It is also used as the basis of ANOVA (Analysis of Variance) to test multiple group
means.
𝑠21
Formula: 𝐹 =
𝑠22
Where:
The test statistic 𝐹follows an F-distribution with (𝑛1 − 1)and (𝑛2 − 1)degrees of freedom.
Problem:
Two different alloys are tested for tensile strength variability.
X 9 25
Y 8 12
Hypotheses:
𝐻0 : 𝜎𝑋2 = 𝜎𝑌2
𝐻1 : 𝜎𝑋2 ≠ 𝜎𝑌2
Calculation:
𝑠𝑋2 25
𝐹= = = 2.083
𝑠𝑌2 12
Page 27 of 57
Degrees of freedom: 𝑣1 = 8, 𝑣2 = 7
At 5% significance level, 𝐹0.05,8,7 = 3.73
Decision:
Since 𝐹 = 2.083 < 3.73,
→ Fail to reject 𝐻0 .
Thus, there is no significant difference between the variances of the two alloys.
Example Use Checking if two machines produce Checking if two machines have
same mean size equal variability
Both t-tests and F-tests are vital tools in engineering statistics for comparing means and variances,
respectively. They help engineers make objective, data-driven decisions when evaluating
materials, designs, and manufacturing processes. Correct application ensures reliable conclusions
and improved engineering outcomes.
Page 28 of 57
• Machine Learning: Basis for linear regression, ridge regression, and LASSO.
Advantages:
• Computationally efficient.
Limitations:
• Sensitive to outliers.
The Ordinary Least Squares (OLS) method is a fundamental tool in statistical modeling,
providing a simple yet powerful way to estimate relationships between variables. It serves as the
basis for many advanced modeling techniques used in modern data science, artificial intelligence,
and engineering systems analysis. A clear understanding of OLS equips engineers with the ability
to interpret data, detect trends, and make predictions with mathematical precision.
Example:
X Y
1 2
2 3
3 5
4 4
𝑋ˉ = 2.5, 𝑌ˉ = 3.5
Page 29 of 57
(1 − 2.5)(2 − 3.5) + (2 − 2.5)(3 − 3.5) + (3 − 2.5)(5 − 3.5) + (4 − 2.5)(4 − 3.5)
𝛽̂1 =
(1 − 2.5)2 + (2 − 2.5)2 + (3 − 2.5)2 + (4 − 2.5)2
4.5
= = 0.9
5
𝛽̂0 = 3.5 − 0.9(2.5) = 1.25
In engineering and scientific studies, we often deal with large populations of data, such as network
traffic, production quality, system response times, or sensor readings. Analyzing the entire
population is often impractical or impossible, so we rely on sampling (selecting a representative
subset of the population).
Sampling Distributions and Statistical Inference provide the mathematical foundation for
making predictions or decisions about populations based on sample data.
A sampling distribution is the probability distribution of a given statistic (like the mean, variance,
or proportion) based on a random sample drawn from a population.
In other words, if we take multiple samples from a population and compute a statistic (e.g., the
sample mean) for each, the distribution of those statistics forms the sampling distribution.
1 𝑛
• Sample variance: 𝑆 2 = 𝑛−1 ∑𝑖 =1(𝑋𝑖 − 𝑋ˉ)2
𝑥
• Sample proportion: 𝑝̂ = 𝑛
𝐸(𝑋ˉ) = 𝜇
𝜎2
𝑉𝑎𝑟(𝑋ˉ ) =
𝑛
Page 30 of 57
8.3 Central Limit Theorem (CLT)
The Central Limit Theorem states that, regardless of the shape of the population distribution, the
distribution of the sample mean 𝑋ˉ approaches a normal distribution as the sample size 𝑛 becomes
large (typically 𝑛 ≥ 30).
𝜎2
𝑋ˉ ∼ 𝑁(𝜇, )
𝑛
Example 1:
A sensor in a network node records the packet transmission time, which is normally distributed
with mean 𝜇 = 50ms and standard deviation 𝜎 = 10ms.
Find:
Solution:
𝐸(𝑋ˉ) = 𝜇 = 50
𝜎 10
𝑆𝐷(𝑋ˉ ) = = =2
√ 𝑛 √ 25
Convert to Z-scores:
48 − 50 52 − 50
𝑃(48 < 𝑋ˉ < 52) = 𝑃( <𝑍 < )
2 2
= 𝑃(−1 < 𝑍 < 1) = 0.6826
Interpretation:
There is a 68.26% chance that the sample mean transmission time is between 48 ms and 52 ms.
Page 31 of 57
Statistical inference involves using sample data to draw conclusions or make decisions about a
population. It includes two major processes
• Hypothesis Testing
8.5 Estimation
1. Point Estimation
Example:
Sample mean 𝑋ˉ is a point estimate of population mean 𝜇.
A confidence interval (CI) gives a range of values that is likely to contain the population
parameter with a certain level of confidence (e.g., 95%).
𝜎
𝐶𝐼 = 𝑋ˉ ± 𝑍𝛼/2
√𝑛
A sample of 10 resistors has an average resistance of 100 Ω with a standard deviation of 5 Ω. Find
the 95% confidence interval for the true mean resistance.
Interpretation:
We are 95% confident that the true mean resistance lies between 96.42 Ω and 103.58 Ω.
Page 32 of 57
8.6 Hypothesis Testing
Hypothesis testing helps engineers decide whether sample data provides enough evidence to
support or reject a claim about the population.
A manufacturer claims that the mean lifetime of a battery is 500 hours. A random sample of 16
batteries has a mean of 490 hours and standard deviation of 20 hours. Test the claim at a 5%
significance level.
𝐻0 : 𝜇 = 500𝐻1 : 𝜇 ≠ 500
𝑛 = 16, 𝑋ˉ = 490, 𝑠 = 20
𝑋ˉ − 𝜇 490 − 500
𝑡= = = −2.0
𝑠/√ 𝑛 20/4
Conclusion:
There is no significant evidence that the mean lifetime differs from 500 hours.
Page 33 of 57
8.7 Applications in Engineering
Conclusion
Sampling distributions and statistical inference are powerful tools for engineers to make data-
driven decisions under uncertainty. Understanding these concepts allows engineers to:
In essence, these methods are essential for ensuring quality assurance, reliability, and
optimization in engineering systems.
Example
Suppose the lifetimes of capacitors follow a distribution with mean 𝜇 = 2000 hours and 𝜎 =
400hours.
If 𝑛 = 64capacitors are tested, find the probability that their average lifetime exceeds 2100
hours.
𝑋ˉ − 𝜇 2100 − 2000
𝑍= = =2
𝜎/√ 𝑛 400/8
Page 34 of 57
• Decision-Making: The results from both methods can lead to similar conclusions. If a confidence
interval for a parameter does not contain the null hypothesis value, it suggests that the null
hypothesis can be rejected at a corresponding significance level.
• Complementary Tools: A confidence interval provides a range of plausible values for the
population parameter, while hypothesis testing provides a binary decision (reject/not reject the null
hypothesis).
A confidence interval provides a range of plausible values for a population parameter (e.g., mean,
proportion).
𝜎
For a normal distribution with known 𝜎: 𝐶𝐼 = 𝑋ˉ ± 𝑍𝛼/2 √𝑛
𝑠
If 𝜎is unknown, we use the t-distribution: 𝐶𝐼 = 𝑋ˉ ± 𝑡𝛼/2, 𝑛−1
√𝑛
where:
• Confidence level = 1 − 𝛼
Suppose 25 CPU speeds are measured, with a sample mean of 3.2 GHz and sample standard
deviation 0.4 GHz. Find the 95% confidence interval for the true mean CPU speed.
𝑠 0.4
𝐶𝐼 = 𝑋ˉ ± 𝑡𝛼/2, 𝑛−1 = 3.2 ± (2.064) = 3.2 ± 0.165
√𝑛 5
Page 35 of 57
Thus, the 95% CI is (3.035 GHz, 3.365 GHz).
Interpretation: We are 95% confident that the true mean CPU speed lies within this range.
9. Hypothesis Testing
A hypothesis is an assumption or claim about a population parameter (like the mean, proportion,
or variance).
Hypothesis testing is a statistical procedure used to determine whether the data collected from a
sample provides enough evidence to support or reject this claim.
The null hypothesis (H₀) is the default assumption or claim that there is no difference, no effect,
or no change.
The alternative hypothesis (H₁) is what you want to test or prove. It contradicts the null hypothesis.
The level of significance (α) is the probability of rejecting a true null hypothesis (Type I error).
Common choices: 𝛼 = 0.05,0.01,0.10
Test Statistic
A test statistic is a standardized value calculated from the sample data that is used to decide whether
to reject the null hypothesis.
6. Decision Rule:
7. Conclusion:
State the interpretation of the result in the problem’s context.
Problem:
A manufacturer claims that the mean lifetime of a type of LED bulb is 10,000 hours. A random
sample of 36 bulbs has an average lifetime of 9,800 hours, with a standard deviation of 600 hours.
Test at a 5% significance level whether the claim is valid.
Solution:
Page 37 of 57
Step 1:
𝐻0 : 𝜇 = 10000
𝐻1 : 𝜇 ≠ 10000(two-tailed test)
Step 2:
Significance level 𝛼 = 0.05
Step 3:
Population standard deviation unknown, but 𝑛 = 36(large sample) ⇒ Z-test
Step 4:
𝑋ˉ − 𝜇
𝑍=
𝑠 /√ 𝑛
9800 − 10000 −200
𝑍= = = −2
600/√ 36 100
Step 5:
From Z-table, for 𝛼 = 0.05, 𝑍0.025 = ±1.96
Step 6:
∣ 𝑍 ∣= 2 > 1.96 ⇒ Reject 𝐻0
Step 7: Conclusion:
There is sufficient evidence to conclude that the mean lifetime is significantly different from
10,000 hours.
Problem:
A new algorithm claims to reduce average execution time below 50 ms. A random sample of 10
runs gives an average time of 47 ms with a standard deviation of 4 ms. Test at the 1% significance
level.
Solution:
Step 1:
𝐻0 : 𝜇 = 50
𝐻1 : 𝜇 < 50(left-tailed test)
Step 2:
Page 38 of 57
𝛼 = 0.01
Step 3:
Population standard deviation unknown, 𝑛 < 30⇒ t-test
Step 4:
𝑋ˉ − 𝜇 47 − 50 −3
𝑡= = = = −2.374
𝑠 /√ 𝑛 4/√ 10 1.264
Step 5:
Degrees of freedom 𝑑𝑓 = 𝑛 − 1 = 9
From t-table, 𝑡0.01 ,9 = −2.821
Step 6:
∣ 𝑡 ∣= 2.374 < 2.821 ⇒ Fail to reject 𝐻0
Step 7: Conclusion:
There is not enough evidence to conclude that the new algorithm significantly reduces execution
time below 50 ms.
Problem:
A machine produces metal rods with a target variance of 0.04 𝑐𝑚2 . A sample of 10 rods has a
sample variance of 0.08 𝑐𝑚2 . Test at 5% significance level if the machine’s variance is still within
acceptable limits.
Solution:
Step 1:
𝐻0 : 𝜎 2 = 0.04
𝐻1 : 𝜎 2 ≠ 0.04
Step 2:
𝛼 = 0.05, 𝑛 = 10
Step 3:
Use Chi-square test:
2
(𝑛 − 1)𝑠 2 (10 − 1)(0.08)
𝜒 = = = 18
𝜎2 0.04
Page 39 of 57
Step 4:
Degrees of freedom 𝑑𝑓 = 9
From χ² table:
2 2
𝜒0.025 ,9 = 19.02, 𝜒0.975 ,9 = 2.70
Step 5:
2.70 < 18 < 19.02 ⇒ Fail to reject 𝐻0
Step 6: Conclusion:
The variance has not significantly changed from the target value of 0.04 𝑐𝑚2 .
Problem:
Solution:
𝐻0 : 𝜎12 = 𝜎22
𝐻1 : 𝜎12 ≠ 𝜎22
𝑠12 0.25
𝐹= 2= = 2.5
𝑠2 0.10
Degrees of freedom:
𝑑𝑓1 = 7, 𝑑𝑓2 = 9
Conclusion:
There is no significant difference in variance between the two servers’ response times.
Field Example
Page 40 of 57
Computer Networks Testing if new routing algorithm improves packet delivery time
Software Engineering Verifying if code optimization reduces CPU usage
Manufacturing Checking if new process affects mean product length
Data Science / AI Comparing model accuracies on two datasets
Electronics Testing if the mean voltage output differs from specification
Conclusion
By properly setting hypotheses and interpreting results, engineers can make reliable inferences
and minimize decision errors.
𝑋ˉ − 𝜇0
𝑍=
𝜎/√ 𝑛
Example:
Page 41 of 57
𝑋ˉ − 𝜇0
𝑡=
𝑠/√ 𝑛
Example:
A sample of 16 processors has an average power usage of 65 W and 𝑠 = 5W. Test 𝐻0 : 𝜇 = 60at
5% significance.
65 − 60
𝑡= =4
5/4
In hypothesis testing, we make decisions based on sample data, but every decision carries a risk
of error.
Even with perfect experimental design and calculations, there is always a chance of making an
incorrect conclusion.
The two kinds of possible mistakes are known as Type I and Type II errors.
Understanding these errors is vital for engineers, because design choices, quality control, and
algorithm evaluation often depend on statistical decisions.
Definition: A Type I error occurs when the null hypothesis ((H_0)) is rejected when it is actually
true. In simpler terms, it is the mistake of finding evidence for an effect or difference that does
not actually exist.
• Symbol: The probability of making a Type I error is denoted by (alpha), often referred to as the
"significance level." Common choices for (alpha) are 0.05 (5%) and 0.01 (1%).
Page 42 of 57
• Example: Suppose a medical test is designed to detect a disease. A Type I error would occur if
the test indicates that a person has the disease (rejecting the null hypothesis that they do not have
it) when in fact they are healthy
Symbol: 𝛼(alpha)
Interpretation: Probability of rejecting a true H₀.
𝑃(Type I Error) = 𝛼
If the test concludes that latency is reduced when it actually isn’t, a Type I error has occurred.
Definition: A Type II error occurs when the null hypothesis ((H_0)) is not rejected when it is
actually false. In other words, it is the mistake of failing to find evidence for an effect or
difference that does exist.
• Symbol: The probability of making a Type II error is denoted by (beta). The power of a test
(which is the probability of correctly rejecting a false null hypothesis) is given by (1 - beta).
• Example: Continuing with the medical test example, a Type II error would occur if the test
indicates that a person does not have the disease (failing to reject the null hypothesis) when in
fact they do have it.
Symbol: 𝛽(beta)
Interpretation: Probability of failing to detect a real effect.
𝑃(Type II Error) = 𝛽
Page 43 of 57
Example (Engineering Context):
If the new algorithm truly reduces latency, but the test fails to detect it, a Type II error occurs.
Power = 1 − 𝛽
Example of Trade-off:
Problem:
Page 44 of 57
• H₀: μ = 5 V
• H₁: μ ≠ 5 V
• α = 0.05
If the test statistic exceeds the critical range (say due to random variation) and the engineer
rejects H₀ even though μ = 5 V in reality, that is a Type I error.
Problem:
Suppose the true mean voltage has dropped to 4.8 V, but the test does not detect this change
(fails to reject H₀).
The power of the test (1 − β) represents how effectively the test can detect such deviations.
• H₁: Mean compression ratio (B) > Mean compression ratio (A)
Trade-off:
Setting α = 0.01 reduces false positives (Type I) but increases β, making it harder to detect small
improvements.
Page 45 of 57
10.4 Factors Affecting Type I and Type II Errors
Increasing sample size is often the best way to reduce both errors simultaneously.
Example
Page 46 of 57
11. Multiple Regression
Multiple Regression is an extension of simple linear regression that models the relationship
between one dependent variable (Y) and two or more independent variables (X₁, X₂, …, Xₖ).
𝑌 = 𝛽0 + 𝛽1 𝑋1 + 𝛽2 𝑋2 + ⋯ + 𝛽𝑘 𝑋𝑘 + 𝜀
Where:
• 𝛽1 , 𝛽2 , … , 𝛽𝑘 : Regression coefficients
Page 47 of 57
11.1 Estimation of Regression Coefficients
The regression coefficients are estimated using the Least Squares Method, which minimizes the
sum of squared residuals (differences between observed and predicted Y values).
In matrix form: 𝐘 = 𝐗𝜷 + 𝜺
̂ = (𝐗 𝑇 𝐗)−1 𝐗 𝑇 𝐘
Where, 𝜷
This equation gives the best linear unbiased estimates (BLUE) of regression coefficients under
the classical assumptions.
Problem Statement:
A computer engineer wants to predict the CPU load (Y) of a server based on:
• X₁ = Number of active processes
𝑌 = 𝛽0 + 𝛽1 𝑋1 + 𝛽2 𝑋2 + 𝜀
𝑌̂ = 10 + 0.8𝑋1 + 0.2𝑋2
Step 3: Interpretation
• Intercept (β₀ = 10): When both X₁ and X₂ are zero, expected CPU load is 10%.
Page 48 of 57
• β₁ = 0.8: Each additional process increases CPU load by 0.8%, holding X₂ constant.
• β₂ = 0.2: Each additional 1 MB/s of network usage increases CPU load by 0.2%, holding
X₁ constant.
𝑌̂ = 10 + 0.8(25) + 0.2(75) = 10 + 20 + 15 = 45
𝑌 = 5 + 0.3𝑋1 + 0.05𝑋2
Interpretation:
𝑌̂ = 5 + 0.3(100) + 0.05(200) = 5 + 30 + 10 = 45 ms
The Coefficient of Determination (R²) measures how well the regression model explains the
variability in the dependent variable.
𝑆𝑆𝑟𝑒𝑠
𝑅2 = 1 −
𝑆𝑆𝑡𝑜𝑡
Page 49 of 57
• 𝑅 2 = 1: Perfect fit
• 𝑅 2 = 0: No relationship
2
(1 − 𝑅 2 )(𝑛 − 1)
𝑅𝑎𝑑𝑗 = 1−
𝑛−𝑘 − 1
where
n = number of observations, k = number of predictors.
𝐻0 : 𝛽𝑖 = 0vs.𝐻1 : 𝛽𝑖 ≠ 0
Compute t-statistic:
𝛽̂𝑖
𝑡=
𝑆𝐸(𝛽̂𝑖 )
• X₁ = Temperature (°C)
• X₂ = Pressure (bar)
Model:
Interpretation:
• Increasing temperature by 1°C increases quality score by 0.5 (if other factors constant).
Page 50 of 57
• Increasing processing time by 1 minute decreases quality by 1.5 points.
Field Example
Computer Predicting network throughput based on bandwidth, latency, and packet
Networks loss
Machine Learning Feature-based prediction of target variables (e.g., linear regression
model)
Software Estimating software defects based on lines of code, complexity, and
Engineering testing time
Electronics Modeling circuit output voltage as a function of input voltage,
temperature, and resistance
Manufacturing Predicting product strength using pressure, material ratio, and cooling
rate
Advantages:
Limitations:
• Sensitive to multicollinearity
𝐘 = 𝐗𝛃 + 𝛜
Page 51 of 57
Where:
The least squares estimator of 𝜷is obtained by minimizing the sum of squared residuals:
̂ = (𝐗 𝑇 𝐗)−1 𝐗 𝑇 𝐘
𝜷
and residuals:
̂
𝐞 = 𝐘 −𝐘
Example
An engineer wants to model CPU performance (𝑌) as a function of clock speed (𝑋1) and number
of cores (𝑋2 ).
𝑌̂ = 50 + 70𝑋1 + 25𝑋2
Interpretation:
• Adding one core increases performance by 25 units, keeping other factors constant.
Page 52 of 57
12. Miscellaneous
The R-squared value indicates how well the model fits the data:
𝑆𝑆𝑟𝑒𝑠
𝑅2 = 1 −
𝑆𝑆𝑡𝑜𝑡
Where:
12.2 Adjusted R²
Adding more predictors can artificially inflate 𝑅 2 . The adjusted R² compensates for this:
2
(1 − 𝑅 2 )(𝑛 − 1)
𝑅𝑎𝑑𝑗 = 1−
𝑛−𝑘 − 1
𝛽̂𝑖
𝑡𝑖 =
𝑆𝐸(𝛽̂𝑖 )
12.4 Autocorrelation
Autocorrelation is the correlation of a signal or variable with a lagged version of itself over
successive time intervals. It is widely used in time series analysis and signal processing.
Page 53 of 57
For a stationary discrete-time series 𝑋𝑡 , the autocorrelation function (ACF) at lag 𝑘is:
𝐶𝑜𝑣(𝑋𝑡 , 𝑋𝑡−𝑘 ) 𝐸[(𝑋𝑡 − 𝜇)(𝑋𝑡−𝑘 − 𝜇)]
𝜌𝑘 = =
𝑉𝑎𝑟(𝑋𝑡 ) 𝜎2
Where:
2. ∣ 𝜌𝑘 ∣≤ 1
3. 𝜌−𝑘 = 𝜌𝑘 (symmetry)
Example
For lag 𝑘 = 1:
5
1
𝐶𝑜𝑣(𝑋𝑡 , 𝑋𝑡−1 ) = ∑(𝑋𝑡 − 𝜇)(𝑋𝑡−1 − 𝜇)
𝑛−1
𝑡 =2
1
= [(4 − 6)(2 − 6) + (6 − 6)(4 − 6) + (8 − 6)(6 − 6) + (10 − 6)(8 − 6)]
4
1 1
= [(−2)(−4) + 0 ∗ (−2) + 2 ∗ 0 + 4 ∗ 2] = [8 + 0 + 0 + 8] = 4
4 4
4
𝜌1 = = 0.5
8
Page 54 of 57
12.6 Cross-Correlation
Cross-correlation measures the correlation between two different signals or time series 𝑋𝑡 and
𝑌𝑡 at different lags.
𝐶𝑜𝑣(𝑋𝑡 , 𝑌𝑡−𝑘 ) 𝐸[(𝑋𝑡 − 𝜇𝑋 )(𝑌𝑡−𝑘 − 𝜇𝑌 )]
𝑟𝑋𝑌 (𝑘) = =
𝜎𝑋 𝜎𝑌 𝜎𝑋 𝜎𝑌
• 𝑘 < 0: Y leads X
Example
Page 55 of 57
Example
𝑋ˉ = 2, 𝑌ˉ = 5
1
𝐶𝑜𝑣(𝑋, 𝑌) = [(1 − 2)(4 − 5) + (2 − 2)(5 − 5) + (3 − 2)(6 − 5)]
3
1 2
= [1 + 0 + 1] = ≈ 0.667
3 3
Example
Page 56 of 57
Variance: 𝑉𝑎𝑟(𝑋) = 1, 𝑉𝑎𝑟(𝑌) = 4, 𝑉𝑎𝑟(𝑍) = 8
1 2
1 = 0.5 ≈ 0.707
√1 ∗ 4 √1 ∗ 8
𝑅=[ 4 ]
0.5 1 = 0.707
√4 ∗ 8
0.707 0.707 1
Page 57 of 57