0% found this document useful (0 votes)
11 views6 pages

New cp3

The document outlines the application of the Least Squares method for predicting sales based on advertising spend, detailing the mathematical foundation, model representation, and solution methods. It includes a practical example with MATLAB code implementation to compute the best-fit line and predict sales for a given advertising spend. The document also discusses future scope and potential applications of the method.

Uploaded by

Deepti Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views6 pages

New cp3

The document outlines the application of the Least Squares method for predicting sales based on advertising spend, detailing the mathematical foundation, model representation, and solution methods. It includes a practical example with MATLAB code implementation to compute the best-fit line and predict sales for a given advertising spend. The document also discusses future scope and potential applications of the method.

Uploaded by

Deepti Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

TABLE OF CONTENTS

TITLE
LIST OF FIGURES 4
LIST OF SYMBOLS AND ABBREVIATIONS 5-6
1.0 INTRODUCTION 7
1.1 Mathematical Foundation of Least Squares 7

1.2 Background of Library Resource Wastage

1.3 Applications and Concept Behind the Method 7

2.0 THE MODEL 8


2.1 Mathematical Representation of the Linear Model 8

2.2 Residuals and Error Minimization 8

3.0 METHOD OF SOLUTIONS 9


3.1 The Normal Equations Approach 9

3.2 The Orthogonal Columns Approach 9

3.3 Uniqueness Solution

3.4 MATLAB code Implementation

4.0 RESULT AND DISCUSSION 10


4.1 Best-Fit Line Example 10-13

4.2 Real-Life Matrix Computation (Sales Prediction)

4.3 Iterative Computation Steps 14

5.0 CONCLUSION 15
6.0 FUTURE SCOPE 16
Real-Life Application: Predicting Sales from Advertising Spend
A business wants to predict its future sales based on how much it spends on advertising.
They collect the following monthly data:

They decide to use the Method of Least Squares to find a linear model:

Q) Predict sales when advertising spend is ₹22,000 (i.e., x = 22)

Matrix Form of Least Squares (Ax = b)


Step 1: Construct Matrix A and Vector b

Step 2: Use the Normal Equation


Step 3: Compute Each Term

Final:
y=12+1.5x

This method is general and works for any number of data points or variables.
MATLAB code Implementation

% Given data (Advertising Spend in x and Sales in y)


x = [10; 15; 20; 25; 30]; % Advertising spend in ₹1000
y = [25; 35; 45; 50; 55]; % Sales in ₹1000
% Step 1: Create the design matrix A
A = [ones(length(x), 1), x]; % The matrix A has a column
of ones for intercept 'a' and column for x
% Step 2: Solve using the normal equation: x = (A^T *
A)^-1 * A^T * b
A_transpose = A'; % Transpose of A
A_transpose_A = A_transpose * A; % A^T * A
A_transpose_b = A_transpose * y; % A^T * b
% Step 3: Calculate the coefficients (a and b)
coefficients = inv(A_transpose_A) * A_transpose_b;
% Display the results
a = coefficients(1); % Intercept
b = coefficients(2); % Slope
disp(['Intercept (a) = ', num2str(a)])
disp(['Slope (b) = ', num2str(b)])
% Step 4: Predict sales for x = 22 (₹22,000 advertising
spend)
x_new = 22; % New advertising spend
y_pred = a + b * x_new; % Predicted sales
disp(['Predicted sales for ₹22,000 ad spend: ₹',
num2str(y_pred * 1000)])
% Optional: Plot the data and the best-fit line
figure;
plot(x, y, 'bo', 'MarkerFaceColor', 'b'); % Plot the data
points
hold on;
y_line = a + b * x; % Best-fit line values
plot(x, y_line, '-r', 'LineWidth', 2); % Plot the
best-fit line
xlabel('Advertising Spend (₹1000)');
ylabel('Sales (₹1000)');
title('Least Squares Fit: Sales vs Advertising Spend');
legend('Data points', 'Best-fit line');
grid on;

You might also like