Models and basic statistics (mean, median, mode, variance, standard deviation, probability), data collection/cleaning/transformation, building and evaluating statistical models (linear regression, logistic regression, K-means) with ethics, and data visualisation types and spreadsheet tools.
9 MCQs · 6 long questions · 6 short questions · 1 numericals · 3 table-based
The chapter's topics and page numbers follow the official textbook. Lessons, lectures and practice are added after academic review.
Lessons
5.4.1.1 Model Development
5.4.1.1 Model Development · Reviewed lesson · version 1 · published 16 Nov 2026
Building a statistical model involves several steps. Let's break them down:
Step 1: Define the Problem
First, we need to understand the problem. Example: If we are trying to predict grocery expenses, we need to know which factors will cause to increase our grocery expenses (e.g., family size, location, or income).
Step 2: Collect Data
Next, we gather data related to the problem. In our example, we will collect data on past spending habits, number of family members, and any other factors that may affect grocery costs.
Step 3: Choose an Algorithm
Based on the problem and the data, we choose an algorithm. Algorithms are methods that help us create a model. Some popular algorithms are linear regression and logistic regression, which we will further in this section.
Step 4: Train the Model
The model is then trained using the data. This means the model learns from the data to make predictions.
Step 5: Evaluate the Model
Finally, we test the model to see how well it works by using new data. This step is very important to ensure the model makes good predictions.
5.5.1.4 Scatterplots · Reviewed lesson · version 1 · published 16 Nov 2026
Images and handouts: 49 KB
Scatterplots display relationships between two variables. Each point represents an observation, and the position on the graph indicates values for both variables.
Example: A scatterplot can be used to explore the relationship between the number of hours studied and exam scores.
Figure 5.7: Scatterplot showing the relationship between hours studied and exam scores (original drawing after the textbook's Figure 5.7).
5.4.1 Introduction to Statistical Modeling · Reviewed lesson · version 1 · published 16 Nov 2026
Statistical modeling is a way to use data to make sense of the world and predict what will happen in the future. Think of it like this: if you want to know how much money you'll spend on groceries next month, you can look at what you spent in the past. By analyzing that data, you can create a model to help you estimate your future grocery expenses.
Example: If you usually spend around 10,000 rupees each month, but your expenses fluctuate, a statistical model can take into account factors like your family size or special occasions. This way, you can get a better idea of how much you may need to budget for your groceries of next month.
5.4 Building Statistical Models · Reviewed lesson · version 1 · published 16 Nov 2026
In this section, we will explore the basic building blocks of statistical models, including different types of models, how they are developed, and how to evaluate their performance. We'll also look at real-world examples to make the concepts easy to understand.
Summary · Reviewed lesson · version 1 · published 16 Nov 2026
This unit focuses on model building and data visualization, equipping learners with the skills to analyze, interpret, and present data effectively. Key topics include:
Model Building:
Understand the role and importance of statistical models in solving real-world problems.
Learn to build basic statistical models (e.g., linear regression) and evaluate their performance using appropriate metrics.
Experimental Design:
Gain an understanding of experimental design in data science, including hypothesis testing, control groups, and randomization.
Data Visualization:
Explore the types and uses of data visualizations (e.g., bar charts, scatter plots, heatmaps).
Learn methods
5.4.2.3 Ethical Considerations
5.4.2.3 Ethical Considerations · Reviewed lesson · version 1 · published 16 Nov 2026
When building models, it is important to consider the ethical implications, such as fairness and privacy.
Fairness and Bias
A model should be fair and not biased. For example, if a model is used to decide who gets a loan, it should not unfairly favor one group of people over another.
Data Privacy
When using personal data to build models, it is important to respect privacy. For example, if a company is using customer data to build models, they should ensure the data is secure and not shared without permission.
Class Activity: Linear Regression
You are given the following data that shows the relationship between the number of hours studied and the marks obtained in a test by students. Your task is to build a linear regression model that predicts the marks based on the number of hours studied.
Hours studied and marks obtained
Hours Studied
5.5 Introduction to Data Visualization
5.5 Introduction to Data Visualization · Reviewed lesson · version 1 · published 16 Nov 2026
Data visualization is the process of representing data in a visual format, such as graphs or charts. It helps us to quickly grasp patterns, trends, and insights from data.
5.2 Basic Statistical Concepts · Reviewed lesson · version 1 · published 16 Nov 2026
Statistics is a branch of mathematics that helps us understand and analyze data. By using statistics, we can summarize large sets of information in a simple way, making it easier to draw conclusions. Some basic statistical concepts are descriptive statistics, measures of central tendency, measures of dispersion, and probability.
5.5.1.3 Histograms · Reviewed lesson · version 1 · published 16 Nov 2026
Images and handouts: 72 KB
Histograms are used to show the distribution of a dataset. They group data into bins or intervals, allowing you to see how frequently values occur within those ranges.
Example: If you want to analyze how students performed in an math exam, a histogram can show the distribution of scores.
Figure 5.6: Example of a Histogram showing the distribution of exam scores (original drawing after the textbook's Figure 5.6).
5.6.2 Creating and Interpreting Visualizations · Reviewed lesson · version 1 · published 16 Nov 2026
Step-by-Step Guide: Here's a simple guide to creating a visualization in Excel or Google Sheets.
Enter Your Data: Start by entering your data into the spreadsheet. Example: In one column, you could have the months (January, February, etc.), and in another column, the sales figures for each month.
Select the Data: Highlight the data you want to visualize by clicking and dragging your mouse over the cells.
Choose a Chart Type: Click on the "Insert" tab and select the type of chart you want to create (bar chart, line graph, etc.).
Customize the Chart: You can add labels to your chart to make it clearer, such as labeling the x-axis with the months and the y-axis with the sales figures. This makes the chart easier to interpret.
Understanding Statistical Representations: When you create a visualization, it's important to understand what the chart is telling you.
Example: Bar Charts: Useful for comparing different categories, such as monthly sales.
Line Graphs: Ideal for showing trends over time, like how sales have increased or decreased over several months.
5.3.3.1 Data Cleaning · Reviewed lesson · version 1 · published 16 Nov 2026
Data cleaning means correcting or removing any problems in the data. These problems can include incorrect entries, missing values, or duplicate data. If these errors are not fixed, the results of the analysis will be misleading.
Example: Imagine a school collecting data on student grades. Some students may have entered their names incorrectly, or a few grades may be missing from the records. In this case, data cleaning would involve correcting any wrong names and finding the missing grades to complete the dataset. Figure 5.2, illustrates the data cleaning process for student grades in a school. It shows examples of common issues such as incorrect names, missing grades, and duplicate entries.
Table 5.2: Graphical Representation of Data Cleaning for Student Grade Records. Original Data (with Errors)
Name
Grade
Class
Section
Ali
85
10
A
5.1.1 Definition and Importance of Models
5.1.1 Definition and Importance of Models · Reviewed lesson · version 1 · published 16 Nov 2026
In simple terms, a model is a simplified way of looking at a complex problem or situation. It helps to understand, explain, or predict how things work. Just like a map helps someone navigate a city by showing roads and landmarks, a model helps us understand a problem by focusing on the most important parts and leaving out unnecessary details.
Example: Consider a student preparing for exams. To decide how much time to spend on each subject, the student creates a study plan. This plan is a model that simplifies their schedule by focusing on important subjects and ignoring less relevant tasks.
5.4.2.1 Performance Metrics · Reviewed lesson · version 1 · published 16 Nov 2026
Performance metrics help us measure how well a model is doing. Some common metrics include:
Error Metrics
Error metrics measure how much the model's predictions differ from the actual values. In our grocery example, if the model predicts a monthly grocery bill of 8,000 rupees but the actual bill is 10,000 rupees, the difference is the error.
Accuracy Metrics
Accuracy metrics tell us how many of the model's predictions were correct. For example, if a model predicts whether a student will pass or fail an exam, accuracy measures how often the model was right.
5.5.1.1 Bar Charts · Reviewed lesson · version 1 · published 16 Nov 2026
Images and handouts: 66 KB
Bar charts are ideal for comparing different categories. Each bar represents a category, and the height (or length) of the bar indicates the value associated with that category.
Example: Imagine you want to compare the sales figures for different products in a store. A bar chart can visually represent this data.
Figure 5.4: A bar chart showing sales figures of different products (original drawing after the textbook's Figure 5.4).
5.5.1.5 Boxplots · Reviewed lesson · version 1 · published 16 Nov 2026
Images and handouts: 68 KB
Boxplots, or whisker plots, summarize data distribution by displaying the median, quartiles, and potential outliers. They provide a visual summary of data variability.
Example: A boxplot can be used to compare the exam scores of different classes to see which class performed better overall.
Figure 5.8: A Boxplot, showing class scores performance of three classes (original drawing after the textbook's Figure 5.8).
5.6 Tools for Data Visualization · Reviewed lesson · version 1 · published 16 Nov 2026
As we discuss above section visualization data helps us make sense of large amounts of information by turning numbers into easy-to-understand charts and graphs. In this section, we will discuss tools that can be used to create these visualizations and guide you through how to create and interpret them step by step.
There are many tools available for creating data visualizations, but some of the easiest to use are tools you are already be familiar with, like Microsoft Excel and Google Sheets. These tools are widely accessible and provide straightforward methods to create charts, graphs, and other visual representations of data.
5.3.1.1 Surveys · Reviewed lesson · version 1 · published 16 Nov 2026
Surveys are a commonly used method for collecting large amounts of data in a structured way. These involve asking a predefined set of questions to a sample group. Surveys can be conducted using various means such as online forms, telephone calls, or face-to-face interviews.
Example: A small local grocery store in Islamabad wants to know customer preferences regarding which products they would like to see more frequently. They create a short survey consisting of five questions which is depicted in Figureand distribute it to 50 customers over a weekend. The collected responses are then analyzed to stock products that align with customer demand, improving business operations.
Customer Preference Survey
Which product categories do you buy most often? (e.g., fruits, vegetables, dairy)
Are there any products you would like to see more often?
How often do you shop at this grocery store? (e.g., daily, weekly, monthly)
What influences your purchasing decisions the most? (e.g., price, quality, availability)
Any additional comments or suggestions?
Responses collected from 50 customers over the weekend.
5.6.1 Using Excel and Google Sheets for Visualization
5.6.1 Using Excel and Google Sheets for Visualization · Reviewed lesson · version 1 · published 16 Nov 2026
Excel and Google Sheets: These tools allow you to easily enter your data and then generate a variety of visualizations such as bar charts, line graphs, and pie charts.
Example: Let's say you run a small business in your local area, and you want to track how many products you sell each month. You can enter the data for each month in Excel or Google Sheets, and with just a few clicks, you can create a bar chart to see which month had the most sales.
5.2.2 Descriptive Statistics · Reviewed lesson · version 1 · published 16 Nov 2026
Descriptive statistics are used to summarize and organize data. Instead of looking at every individual piece of data, descriptive statistics give us a way to see the overall picture.
Example: Imagine a group of 10 college students takes a math exam, and their scores are: 50, 65, 75, 80, 85, 90, 95, 60, 70, and 88.
To summarize this data:
Mean (Average): The mean score is calculated by adding all the scores and dividing by the number of students.
5.3.3 Data Cleaning and Transformation · Reviewed lesson · version 1 · published 16 Nov 2026
Data cleaning and transformation are important steps to prepare data for analysis. Raw data often has errors, missing values, or may be in the wrong format. To ensure accurate results in analysis, it is important to fix these issues before moving forward.
5.3.3.2 Data Transformation · Reviewed lesson · version 1 · published 16 Nov 2026
Once the data is clean, it is often necessary to transform it into a format that is easy to work with. This transformation may include converting data into different formats, creating new columns, or organizing data in a different way. These changes help make the data more suitable for analysis or modeling.
Example: After cleaning the student grade records, it may be necessary to transform this data for better analysis. For instance, instead of displaying grades for each individual student, the data
5.3.1.2 Observations · Reviewed lesson · version 1 · published 16 Nov 2026
Observation involves collecting data by watching or monitoring subjects in their natural environment. This method is useful when researchers want to gather data on behaviors or phenomena without interference.
Example: A restaurant is interested in knowing which tables are most frequently chosen by customers during lunchtime. A staff member observes the seating choices over a period of one week. Based on this observation, the restaurant arranges its seating to optimize the comfort and flow of customer traffic, which helps in improving customer satisfaction and service efficiency.
5.3.2 Data Preparation · Reviewed lesson · version 1 · published 16 Nov 2026
Once data has been collected, it is important to prepare it for analysis. This includes cleaning the data to remove errors or inconsistencies, organizing it in a meaningful way, and converting it into a format suitable for analysis. In cases where data is missing or incorrect, researchers may need to employ techniques such as interpolation or statistical adjustments to ensure accuracy.
Example: If survey responses contain incomplete information, missing values can be estimated based on the available data. Proper data preparation ensures that the analysis leads to reliable and valid results.
5.4.2.2 Interpreting Outputs · Reviewed lesson · version 1 · published 16 Nov 2026
Interpreting a model's output means understanding what the results tell us.
Drawing Conclusions from Insights
For example, if our linear regression model shows that hours studied strongly affect exam scores, we can conclude that students should study more hours to improve their scores.
5.1.2 Role of Models in Decision-Making · Reviewed lesson · version 1 · published 16 Nov 2026
Models are useful because they give a structured way to think about a problem. They take complicated information and make it easier to work with. This is especially important in decision making, where models help us consider different outcomes before making a choice.
Example: When a farmer use a model to decide the best time to plant crops. By studying weather patterns and soil conditions, the model helps the farmer predict the right planting time, which increases the chances of a good harvest.
5.1.3 Applications of Models · Reviewed lesson · version 1 · published 16 Nov 2026
Models are tools that help us understand complex problems by simplifying them. They are widely used in various fields to make predictions and decisions based on available data. Some common fields where models are applied include weather forecasting, financial predictions, and scientific research.
Weather Forecasting
In weather forecasting, models are used to predict future weather conditions. Meteorologists collect data such as temperature, humidity, and wind speed, and then use models to analyze this data and forecast the weather.
Financial Predictions
Models are also very important in the financial world. Banks and companies use models to predict economic trends, stock prices, and even customer behavior.
Scientific Research
In scientific research, models help scientists test theories, explore new ideas, and make predictions based on data. With advancements in Machine Learning (ML) and Artificial Intelligence (AI), models have become even more powerful and accurate in analyzing large amounts of data.
5.3.3.3 Handling Missing Data · Reviewed lesson · version 1 · published 16 Nov 2026
Sometimes, data is incomplete or has missing values. There are different techniques to handle missing data. One option is to remove the rows with missing values if they are very few. Another option is to fill in the missing values with an average or with data from similar cases. The choice depends on the type of data and the amount of missing information.
Example: In the dataset of student grades, if Sara's grade is missing, this creates a challenge in assessing her performance. To address this issue, several strategies can be employed:
Imputation: One common method is to estimate the missing value using existing data. Example: The school can calculate the average grade of all students in Sara's class. If the average grade is 82, the school may assign this value to Sara's record temporarily. This approach allows the school to maintain a complete dataset while making a reasonable assumption about Sara's performance.
Flagging: The school can also keep track of Sara's missing grade by adding a note in the dataset. This method indicates that Sara's grade is not available, making analysts aware of the incomplete data. This approach ensures transparency while allowing the analysis to proceed without filling in the gap.
Removal: If the number of missing entries is small, the school might choose to exclude Sara's record from specific analyses. This decision is acceptable if it does not significantly impact the overall understanding of student performance. However, it risks losing valuable information about Sara.
5.1 Model Building · Reviewed lesson · version 1 · published 16 Nov 2026
Introduction
Model building is the process of creating simplified representations of complex problems. It helps in understanding, analyzing, and solving real-world issues by focusing on key elements.
5.3 Data Collection and Preparation · Reviewed lesson · version 1 · published 16 Nov 2026
In order to carry out any research or analysis, data collection and preparation are crucial steps. The quality and relevance of the data directly impact the results and insights drawn from the study. This section discusses various methods of data collection and how the collected data is prepared for further analysis.
5.5.1 Types of Visualizations · Reviewed lesson · version 1 · published 16 Nov 2026
Data visualization is a powerful way to understand complex information. Different types of visualizations serve various purposes, making it easier to interpret and analyze data. Below are some common types of visualizations explained in detail:
5.3.1 Data Collection Methods · Reviewed lesson · version 1 · published 16 Nov 2026
Data collection refers to the process of gathering relevant information for a particular purpose. Depending on the nature of the research, different methods can be used for data collection. These methods include surveys, observations, and experiments, each having its own strengths and suitable contexts. Choosing the right method depends on the research objective and the type of data required.
5.3.1.3 Experiments · Reviewed lesson · version 1 · published 16 Nov 2026
Experiments involve manipulating one or more variables to determine their effect on another variable. This method is particularly useful in scientific and engineering fields where controlled environments are necessary for accurate measurement.
Example: A school teacher wants to test whether providing students with printed notes helps improve their performance in exams. The teacher conducts an experiment with two groups of students, one receiving printed notes and the other relying solely on lectures. After one month, both groups take the same test, and the teacher compares the results to see if printed notes had a positive impact on performance.
5.4.1.3 Logistic Regression · Reviewed lesson · version 1 · published 16 Nov 2026
Logistic regression is a powerful tool used when we want to predict an outcome that can be categorized as “yes” or “no”.
Example: Let's say we want to determine whether a student will pass or fail an exam based on the number of hours they study. Instead of giving a specific score, logistic regression helps us find the probability of passing.
Understanding Logistic Regression
Logistic regression is different from linear regression because it doesn't predict exact numbers. Instead, it provides a probability value between 0 and 1. This means it tells us how likely something is to happen.
Example: If the model predicts a probability of 0.85 for passing the exam, it means there's an 85% chance the student will pass based on their study hours.
Step-by-Step Example
Let's walk through an example with some real data:
Suppose we have the following data on students and their study hours:
Table 5.1: Study Hours vs. Exam Outcomes
Hours Studied
Passed (1) / Failed (0)
5.2.1 Measures of Central Tendency
5.2.1 Measures of Central Tendency (Mean, Median, Mode) · Reviewed lesson · version 1 · published 16 Nov 2026
Measures of central tendency help us find the “center” or typical value in a set of data. There are three main measures of central tendency: mean, median, and mode. These measures give us a sense of the average or most common values in a dataset.
Mean
The mean is the average of all the numbers in a data set. To find the mean, we add all the numbers together and divide by the total number of values.
Example: Imagine 5 students scored 50, 60, 70, 80, and 90 in a test. The mean score is calculated by adding all the scores and then dividing by the number of students: This helps us understand the general performance level of the group.
Median
The median is the middle value when the numbers are arranged in order. If there is an odd number of values, the median is the exact middle number. If there is an even number of values, the median is the average of the two middle numbers.
Example: Using the same test scores: 50, 60, 70, 80, and 90. When we arrange these scores in ascending order (which they already are), the middle value is 70. Therefore, the median score is 70. Example with Even Numbers: If the scores were 50, 60, 70, and 80, we would take the average of the two middle scores (60 and 70):
Median=(60+70)/2=65, the median is 65.
swipeMedian = (60+70)/2 = 65, the median is 65.
5.2.3 Measures of Dispersion
5.2.3 Measures of Dispersion (Variance; 5.2.3.2 Standard Deviation) · Reviewed lesson · version 1 · published 16 Nov 2026
Measures of dispersion tell us how spread out or scattered the data is. Two common measures of dispersion are variance and standard deviation. These help us understand whether the data points are close to the average (mean) or far from it.
Variance
The variance shows how much the numbers in a data set differ from the mean. A higher variance means that the numbers are more spread out, while a lower variance means that the numbers are closer to the mean. To calculate variance, we use the following mathematical formula.
σ2=N1i=1∑N(xi−μ)2
swipeσ² = (1/N) Σ from i=1 to N of (xᵢ − μ)²
5.2.4 Introduction to Probability
5.2.4 Introduction to Probability · Reviewed lesson · version 1 · published 16 Nov 2026
Probability is the study of how likely an event is to happen. It helps us predict outcomes based on what we know.
Example: Consider flipping a coin. There are two possible outcomes: heads or tails. Since both outcomes are equally likely, the probability of getting heads is 50% (or 1/2), and the probability of getting tails is also 50%.
We can express this mathematically as:
Probability=Total nuber of outcomesNumber of favorable outcomes
swipeProbability = Number of favorable outcomes / Total nuber of outcomes
5.4.1.2 Linear Regression
5.4.1.2 Linear Regression · Reviewed lesson · version 1 · published 16 Nov 2026
Linear regression is a common statistical model used to understand the relationship between two variables. It is often used to predict one variable based on another. Let's go through a practical example to explain how it works.
Example: Imagine you run a small fruit stall in your town, and you want to predict how much money you will make each day based on the number of customers who visit your stall. The number of customers is the independent variable (the cause), and the money you earn is the dependent variable (the effect). We will use linear regression to understand this relationship and help you predict future earnings.
Step 1: Collecting Data
To build a linear regression model, we need data. Let's assume you've recorded the number of customers and your daily earnings for the last 5 days:
Number of customers and daily earnings for the last 5 days
Number of Customers
Daily Earnings (in Rupees)
10
500
15
700
5.4.1.4 Introduction To Clustering Techniques (K-means)
5.4.1.4 Introduction To Clustering Techniques (K-means) · Reviewed lesson · version 1 · published 16 Nov 2026
Clustering is a way of grouping similar things together based on their characteristics. Imagine you have a group of students in your class, and you want to divide them into groups based on their performance in different subjects like math, science, and English. Clustering helps us do that by creating groups of students who perform similarly.
Example: Clustering of Students by Performance
Let's say we have data for five students, showing their scores in math and English:
Math and English scores of five students
Student
Math Score
English Score
Basim
85
70
Umer
90
65
Anie
for creating effective visualizations to communicate insights clearly.
Descriptive Statistics:
Understand the benefits of visualizing data through descriptive statistics (e.g., mean, median, standard deviation) to summarize and interpret data trends.
Tools for Visualization:
Develop hands-on skills in creating visualizations using tools like MS Excel, Google Sheets, Python (Matplotlib), and Tableau.
Plot the data points on a graph (Hours studied on the x-axis and Marks obtained on the y-axis).
Calculate the equation of the line using linear regression.
Use the equation to predict the marks for a student who studied for 7 hours.
How well does the model fit the data? Justify your answer by calculating the error between actual and predicted marks.
Class Activity: Logistic Regression
You are a college administrator, and you want to predict whether students will pass or fail a final exam based on their midterm marks. The following data shows the midterm marks of students and whether they passed or failed the final exam. Your task is to build a logistic regression model to predict the likelihood of passing based on midterm marks.
Midterm marks and final exam result
Midterm Marks
Pass (1) / Fail (0)
30
0
40
0
50
0
60
1
70
1
80
1
90
1
swipe
Steps:
Plot the data points (Midterm marks on the x-axis, and Pass/Fail on the y-axis).
Fit a logistic regression model to the data.
Based on the model, predict the probability of passing for a student who scored 55 in the midterm.
Discuss how the logistic regression model helps in making this prediction and whether it's accurate.
Class Activity: K-Means Clustering
You work in a local retail shop, and you want to segment your customers into two groups based on their monthly spending in two categories: groceries and clothing. The following table shows the monthly spending of six customers. Your task is to use K-means clustering to group these customers into two clusters based on their spending habits.
Monthly spending of six customers
Customer
Groceries Spending (in $)
Clothing Spending (in $)
Customer 1
150
100
Customer 2
200
150
Customer 3
100
50
Customer 4
80
20
Customer 5
160
90
Customer 6
40
10
swipe
Steps:
Choose K = 2 clusters and randomly select two initial cluster centers.
Assign each customer to the nearest cluster based on their spending.
Recalculate the cluster centers by finding the average spending in each category for each cluster.
Repeat the process until the cluster centers stabilize.
Analyze the clusters and describe the spending habits of customers in each group.
To create a logistic regression model, we first need to understand our data. Here, the independent variable is the Hours Studied, and the dependent variable is whether the student Passed or Failed.
Creating the Logistic Function:
The logistic regression model gives us an equation like this:
Here, β₀ = 1 and β₁ = 0.6. This means that for each hour studied, the likelihood of passing the exam increases. If a student studies for 5 hours, we can calculate their passing probability:
P(Pass)=1+e−(1+0.6×5)1≈0.83
swipeP(Pass) = 1 / (1 + e^−(1 + 0.6 × 5)) ≈ 0.83
This means there is an 83% chance that the student will pass after studying for 5 hours.
Testing the Model:
Once the model is built, we can use it to make predictions. Let's say a new student studies for 4 hours. We can use our model to find the probability of passing:
The median helps us understand the middle point of the data.
Mode
The mode is the number that appears most often in a data set. There can be more than one mode if multiple numbers appear with the same highest frequency.
Example: If 5 students scored 50, 60, 70, 70, and 90, the number 70 appears twice, while all other numbers appear only once. Therefore, the mode is 70.
Example with Multiple Modes: If the scores were 50, 60, 70, 70, 60, and 90, both 60 and 70 appear twice. So, there are two modes: 60 and 70.
The mode helps us identify the most frequent or common value in the data.
Step 1.2: Compute Each Squared Deviation ((xᵢ−μ)²)
Class A: each score, its deviation from the mean and the squared deviation
xᵢ
xᵢ−μ
(xᵢ−μ)²
50
50−54.8=−4.8
23.04
52
52−54.8=−2.8
7.84
55
55−54.8=0.2
.04
57
57−54.8=2.2
4.84
60
60−54.8=5.2
27.04
swipe
Step 1.3: Compute Variance
σ2=523.04+7.84+0.04+4.84+27.04
swipeσ² = (23.04 + 7.84 + 0.04 + 4.84 + 27.04)/5
62.8/5=12.56
swipe62.8/5 = 12.56
Step 2: Variance for Class B
Given Scores: 30,45,55,75,90
μ=530+45+55+75+90=5295=59
swipeμ = (30 + 45 + 55 + 75 + 90)/5 = 295/5 = 59
Class B: each score, its deviation from the mean and the squared deviation
xᵢ
xᵢ−μ
(xᵢ−μ)²
30
30−59 = −29
841
45
45−59 = −14
196
55
55−59 = −4
16
75
75−59 = 16
256
90
90−59 = 31
961
swipe
Step 2.3: Compute Variance
σ2=5841+196+16+256+961
swipeσ² = (841 + 196 + 16 + 256 + 961)/5
=2270/5=454
swipe= 2270/5 = 454
Variance of Class A: 12.56
Variance of Class B: 454
This confirms that Class B has a much higher variance, meaning the scores are more spread out compared to Class A.
5.2.3.2 Standard Deviation
The standard deviation is similar to variance but provides a more practical number. It tells us how spread out the numbers are in relation to the mean. The standard deviation is simply the square root of the variance. To calculate standard deviation, we use the following mathematical formula.
σ=N1i=1∑N(xi−μ)2
swipeσ = √((1/N) Σ from i=1 to N of (xᵢ − μ)²)
Where: - xᵢ represents each individual value in the data set, - μ is the mean of the data set, - N is the total number of values in the data set.
Calculating Standard Deviation:
Class A:
Standard Deviation=12.56=3.55
swipeStandard Deviation = √12.56 = 3.55
Class B:
Standard Deviation=456=21.26
swipeStandard Deviation = √456 = 21.26
The standard deviation for Class A is approximately 3.55, while for Class B, it is about 21.26. This means that Class A's scores are closely packed around the mean, whereas Class B's scores are more widely scattered. The standard deviation helps us easily understand how much variation there is in the scores.
Probability of heads = (1 favorable outcome, 2 total outcomes)
Probability is not just for coin flips. It is used in many areas, such as predicting the weather, making business decisions, or even playing cricket.
For illustration, you can use the following sample data: 3, 5, 8, 8, 10, 12, 15, 15, 16, 18. But if you are interested in collecting real data from your classmates, you are welcome to do so.
Here, the number of customers is our independent variable (X), and the daily earnings are the dependent variable (Y).
Step 2: Understanding the Linear Regression Formula
The formula for simple linear regression is:
Y=β0+β1x+ϵ
swipeY = β₀ + β₁x + ϵ
Where:
Y is the dependent variable (in our case, daily earnings),
X is the independent variable (the number of customers),
β₀ is the intercept, which is the starting value of Y when X = 0,
β₁ is the slope, which shows how much Y changes with each unit increase in X,
ε is the error term, which accounts for the difference between the predicted and actual values.
Step 3: Building the Linear Regression Model
When building a linear regression model, our goal is to find the best line that explains how two things are related in this case, the number of customers and daily earnings. Here's how we get the values for the slope (40) and intercept (300):
Understanding the Slope (β₁ = 40)
The slope shows how much extra money we make for every new customer. Let's use our data to figure it out:
Customers and earnings (Rupees)
Customers
Earnings (Rupees)
10
500
15
700
20
900
25
1,100
30
1,300
swipe
If you notice, for every 5 extra customers, earnings go up by 200 rupees. So, for each new customer:
β1=200/5=40
swipeβ₁ = 200/5 = 40
This means every new customer adds 40 rupees to our earnings.
Understanding the Intercept (β₀ = 300)
The intercept (β₀) represents the earnings when no customers visit. To find this value, we look at where the line crosses the vertical axis when the number of customers is zero. In simpler terms, it tells us what the base earnings are, even if no one shows up.
Let's look at the data:
Customers and earnings (Rupees)
Customers
Earnings (Rupees)
10
500
15
700
20
900
25
1,100
30
1,300
swipe
Using this data, we calculate the slope (β₁ = 40) means for every additional customer, earnings increase by 40 rupees. Now, to find the intercept, we need to consider how much we earn when there are no customers.
We can use the equation:
Earnings=β0+β1×Customers
swipeEarnings = β₀ + β₁ × Customers
If we take any data point, say when there are 10 customers, the earnings are 500 rupees. Substituting these values into the equation:
500=β0+(40×10)
swipe500 = β₀ + (40 × 10)
500=β0+400
swipe500 = β₀ + 400
Solving this gives:
β0=500−400=100
swipeβ₀ = 500 − 400 = 100
This means that, based on the data, if no customers show up, you'd still expect to make 100 rupees, maybe from regular customers or other fixed earnings. So, the intercept value of 100 rupees represents the minimum amount you'd make on a day with zero customers.
Final Equation:
Earnings=100+40×Customers
swipeEarnings = 100 + 40 × Customers
This equation means:
You'll always earn 100 rupees, even if no one comes.
Each new customer adds 40 rupees to your total.
Step 4: Interpreting the Model
Once the model is built, we can use it to predict future earnings. For example, if you expect 22 customers tomorrow, the predicted earnings would be:
This means that with 22 customers, you can expect to earn around 980 rupees.
Step 5: Testing the Model
After building the model, it's important to test it using new data. Let's say on the 6th day, 28 customers visited your stall, and you earned 1,250 rupees. Using the model, we can predict the earnings for 28 customers:
We can use clustering to group these students based on their performance in these two subjects.
K-means Clustering
K-means clustering is one of the simplest and most popular techniques to group data. In K-means, we need to decide how many groups (clusters) we want. For this example, let's say we want to divide the students into two clusters: one for students who are strong in math and one for students who are strong in English. The algorithm will group students with similar performance in math and English together by calculating the distance between their scores and finding patterns. It will assign students like Basim and Umer (who are good at math) to one group and students like Anie and Tallat (who are good at English) to another group.
Step-by-step Working of K-means:
Step 1: Select the number of clusters (K)
We decide on K = 2, meaning we want to divide the students into two clusters. One cluster will group students who are stronger in math, and the other will group students stronger in English.
Step 2: Place initial group centers
We need to start with two initial cluster centers, chosen randomly from the students' scores.
For simplicity, let's pick two students to act as the centers:
Initial Center 1: Basim (85,70) - for students strong in math.
Initial Center 2: Tallat (40,85) - for students strong in English.
Step 3: Assign each student to the nearest center
We calculate the distance of each student's scores from both cluster centers. The most common way to calculate this is using the Euclidean distance formula:
Distance=(x2−x1)2+(y2−y1)2
swipeDistance = √((x₂ − x₁)² + (y₂ − y₁)²)
Let’s calculate the distance for each student from Center 1 (Ali) and Center 2 (Ayesha):
Basim: Distance to Center 1 = 0 (Since he is the center)
Basim: Distance to Center 2=(40−85)2+(85−70)2=46.1
swipeBasim: Distance to Center 2 = √((40 − 85)² + (85 − 70)²) = 46.1
Umer: Distance to Center 1=(85−90)2+(70−65)2=46.1
swipeUmer: Distance to Center 1 = √((85 − 90)² + (70 − 65)²) = 46.1
Umer: Distance to Center 2=(40−90)2+(85−65)2=57.01
swipeUmer: Distance to Center 2 = √((40 − 90)² + (85 − 65)²) = 57.01
Anie: Distance to Center 1=(85−50)2+(70−80)2=36.4
swipeAnie: Distance to Center 1 = √((85 − 50)² + (70 − 80)²) = 36.4
Anie: Distance to Center 2=(40−50)2+(85−80)2=10.29
swipeAnie: Distance to Center 2 = √((40 − 50)² + (85 − 80)²) = 10.29
Tallat: Distance to Center 1 = 46.1 (Since she is the center)
Tallat: Distance to Center 2 = 0 (Since she is the center)
Maliha: Distance to Center 1=(85−60)2+(70−60)2=26.92
swipeMaliha: Distance to Center 1 = √((85 − 60)² + (70 − 60)²) = 26.92
Maliha: Distance to Center 2=(40−60)2+(85−60)2=32.02
swipeMaliha: Distance to Center 2 = √((40 − 60)² + (85 − 60)²) = 32.02
After calculating these distances, we assign each student to the nearest center. Based on the calculations:
Basim and Umer are closer to Center 1 (Basim), so they join Cluster 1 (Math-strong).
Anie, Tallat, and Maliha are closer to Center 2 (Tallat), so they join Cluster 2 (English-strong).
Step 4: Recalculate the centers.
Now that the students have been assigned to clusters, we need to recalculate the centers by finding the average position (average scores) of the students in each cluster.
For Cluster 1 (Basim and Umer), the new center will be the average of their math and English scores:
New Center 1=285+90,270+65=(87.5,67.5)
swipeNew Center 1 = (85+90)/2, (70+65)/2 = (87.5, 67.5)
For Cluster 2 (Anie, Tallat, and Maliha), the new center will be:
New Center 2=350+40+60,380+85+60=(50,75)
swipeNew Center 2 = (50+40+60)/3, (80+85+60)/3 = (50,75)
Step 5: Repeat steps 3 and 4 until the centers stop moving.
Now that the centers are updated, we will again calculate the distance between each student and the new centers and reassign them if needed. This process continues until the centers no longer change, which means the clusters are stable.
For this example, after recalculating, the cluster centers are already quite stable. Basim and Umer still be closer to the math-strong cluster, and Anie, Tallat, and Maliha would remain in the English-strong cluster.
After these steps, we will get two clusters: Cluster 1: Basim, Umer, and Maliha (good in math) Cluster: 2 Anie and Tallat (good in English)