0% found this document useful (0 votes)
121 views10 pages

Assignment 1: MAT216 - SUMMER 2020

1) The document discusses using cosine similarity to determine which two customers from a list of four customers are best friends based on their similar purchasing habits from a supermarket. 2) It then represents the customers' purchasing data over the past year in matrix form and asks which customer's most recent purchasing does not match their average based on the yearly data. 3) The document introduces the concept of changing coordinate systems by changing the basis vectors and asks the new coordinates of a point in the new basis and the solution to a matrix multiplication problem using the new concept of basis vectors.
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)
121 views10 pages

Assignment 1: MAT216 - SUMMER 2020

1) The document discusses using cosine similarity to determine which two customers from a list of four customers are best friends based on their similar purchasing habits from a supermarket. 2) It then represents the customers' purchasing data over the past year in matrix form and asks which customer's most recent purchasing does not match their average based on the yearly data. 3) The document introduces the concept of changing coordinate systems by changing the basis vectors and asks the new coordinates of a point in the new basis and the solution to a matrix multiplication problem using the new concept of basis vectors.
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/ 10

MAT216 | SUMMER 2020

ASSIGNMENT 1

Prepared By: Azwad Anjum Islam


CHAPTER 1: HOW CLOSE ARE YOU?

We know what a vector is, and we know how to measure the cosine similarity between two vectors
using their dot products (it’s the cosine of the angle between those vectors). Now let’s start off our
1 2
assignment with an easy one, let me give you a couple of vectors, 𝐴⃗ = [2] and 𝐵 ⃗⃗ = [3].
3 4

Q1 (a): What is the cosine similarity between 𝐴⃗ and 𝐵


⃗⃗?

Now that we have done an easy one, let’s try the same thing on a better example. This time, let’s
work with some data from a supermarket, which is named “Duswapno”.
As the leading supermarket of the region, “Duswapno” only sells four items –
➢ Item 1: Egg
➢ Item 2: Milk
➢ Item 3: Bread
➢ Item 4: Limited Edition Ben10 Omnitrix Replica
Labib, Hasib, Rumi, and Benjamin Tennyson visit “Dushwapno” very frequently. This is their
purchase history from the last week –

Labib Hasib Rumi Benjamin


Tennyson
Egg 6 4 8 0
Milk 1 3 1 2
Bread 2 1 1 2
Omnitrix 1 0 1 7

THINK: If I asked you to express Labib’s purchase history using a single vector, how would you
do it? Does the green column work for Labib? Which column represents Hasib?
Now, we ask you the second question – We know, among these four young boys, two are best
friends, and have similar buying/eating habit. Now -

Q1 (b): Using the cosine similarity as a measure, determine, which 2 of these 4 buyers
are best friends? (which two have the most similar buying habit)

2
CHAPTER 1, PART 2: SOMEONE’S ACTING WEIRD
Let’s look at the purchase data of “Duswapno” again. We have four products, and four buyers.
Which means, this purchase history can be expressed compactly using a 4 × 4 matrix, where
each row represents a product, and each column represents a buyer -

Labib Hasib Rumi Benjamin


Tennyson
6 4 8 0
Egg 6 4 8 0 1 3 1 2
Becomes [ ]
Milk 1 3 1 2 2 1 1 2
Bread 2 1 1 2
1 0 1 7
Omnitrix 1 0 1 7

This matrix gives us the purchase history of only the last week. Let’s look at the purchase history
of these 4 buyers for the LAST YEAR –

311 100 415 15


52 259 50 104
[ ]
104 150 51 110
50 0 51 360

Considering that there are 52 weeks in a year, you can find a rough estimation of the average
weekly purchase of each buyer, from the data of the entire year.
THINK: If you buy one bread each week, how many breads do you buy in a year?
Once you determine the weekly estimation from the yearly data, you will see that someone’s
purchase history (our original matrix) from last week, doesn’t match with his average buying habit.

Q1 (c): Who has bought much more/less products than usual in the last week?

3
CHAPTER 2: ONE WAY OR THE OTHER
Look at the following figure -

In a 2-dimensional space, if I asked you what the position of the Brown Point is, you would
probably give me the coordinates (2, 3). That would be correct, but these two numbers 2 and 3
are completely based on our choice of the two axes – the X axis, and the Y axis. The coordinate
(2, 3) simply means, that if I go 2 unit towards the X axis, and 3 units towards the Y axis, I will find
the brown point.
Now, if I remove the XY grid –

you can see that, without first choosing the two axes first, the coordinates (2,3) don’t really mean
anything, because now we don’t know which way should we go forward with those 2 and 3 units.
So, our idea of coordinates is not absolute, it depends on the axes that we choose for our space.
2
For example, the (2,3) coordinate of the brown point is expressed by the vector [ ], which is a
3
linear combination of the two vectors –

• 𝑖̂ (unit vector in the direction of X axis)


• 𝑗̂ (unit vector in the direction of Y axis)
2 1 0
[ ] = 2×[ ]+3×[ ]
3 0 1
The set of these two vectors together is called the standard basis of the 2D space. There are
infinite numbers of such sets. All of those sets are called basis sets for that space.

4
Now, here comes the question. What if we changed our basis? Note that vectors in basis are what
determines our choice of axes. So, if we change the basis, the axes will change as well.
−2 1
Let’s say, instead of 𝑖̂ and 𝑗̂, we choose the following vectors [ ] 𝑎𝑛𝑑 [ ] as our basis set. With
2 1
this new choice of axes, our coordinates will change.

Obviously, the coordinate of the brown point cannot be (2,3) anymore. If you go 2 times of the
green vector in its direction, and then 3 times of the red vector in its direction, you will not reach
the brown point. So what should be the new coordinate?
HINT: Watch Lecture 2(2) if you don’t understand what I mean.

Q2 (a): Let’s say our new coordinate is (𝐧𝐞𝐰𝐱 , 𝐧𝐞𝐰𝐲 ). What is the value of 𝐧𝐞𝐰𝐱 and 𝐧𝐞𝐰𝐲 ?

Moving on, using the concept of linear combination, let’s do a matrix multiplication now,

𝟐 𝟑 𝒙 𝟗 𝑼𝒏𝒌𝒏𝒐𝒘𝒏𝒂 𝟖𝟏
[ ]×[ ]=[ ]
𝟏 𝟑 𝟏 𝒚 𝟏𝟖 𝑼𝒏𝒌𝒏𝒐𝒘𝒏𝒃

I know you can just write a few equations and figure out the value of x and y with a bit of
algebra. But let’s ditch the algebra for now, you can answer this just by thinking.
Try to think from the perspective that, every matrix multiplication can be thought as a linear
combination of the columns of the matrix on the left. And the values in the columns of the right
matrix tells us all about the scalers of that linear combination. So,

Q2 (b): What is the value of x and y? Don’t think about the unknowns for now.
Q2 (c): What is the value of 𝒖𝒏𝒌𝒏𝒐𝒘𝒏𝒂 and 𝒖𝒏𝒌𝒏𝒐𝒘𝒏𝒃?

5
CHAPTER THREE: MIRROR MIRROR ON THE WALL
It’s time to test our Linear Transformation concepts. And for that, we will use this scene from the
Gryffindor common room, where our good friend Harry is practicing some spells in front of a mirror.
Note that the mirror is on the left wall.

What we want to do here is construct the reflection of the whole scene caused by the mirror,
and we already know that Linear Transformation can do that extremely easily. But first of all, for
the transformation to make any sense, we need an origin and a coordinate system to represent
the scene –

Now, everything in this scene has a very specific coordinate, which can be manipulated by a
transformation matrix. As we want to cause a reflection over the Y axis in this particular case, we
are going to use a reflection matrix. Let’s say our desired reflection matrix is –
𝑚11 𝑚12
𝑀 = [𝑚 𝑚22 ]
21

6
𝑎
If we multiply the position of a point [ ] with this reflection matrix M, we will get the corresponding
𝑏
reflected position of that point as a result. Multiplying each and every point’s position with the
matrix will give us the reflection of the entire scene –

Notice how the reflection has affected all the position vectors. I have given two examples (the
golden and green vectors). Now your job is to figure out –

Q3 (a): What are the values in the reflection matrix M?

HINT: Recall how we can determine each columns of the transformation matrix by noticing the
transformation’s effects on the standard unit vectors (𝑖̂ 𝑎𝑛𝑑 𝑗̂). Watch my videos on matrix
transformation again if you forgot.

7
But, 2D is boring, so let’s bring this idea to 3 dimension –

We want to create the reflection of this fine gentlemen over here. The semi-transparent white wall
is our mirror. And again, to make sense of any linear transformation we perform, we first need to
choose a suitable (and convenient) origin and coordinate system –

As you can see here, we have taken our origin and the three axes in such a way that the mirror
is now on the ZY plane. In other words, we are reflecting the scene over the ZY plane.

8
Before we try to find out the reflection matrix, let’s first try to find out the reflection of a single
3 𝑥𝑡
position vector. As you can see, the point [ 8 ] has been reflected to the point [ 𝑦𝑡 ]. What is this
5 𝑧𝑡
new point? It’s easy, you only need your common sense to answer this.

Q3 (b): What is the reflection of the point (3, 8, 5)?

Once you have figured that out, you should have a fairly clear idea about the reflection matrix -

𝑟11 𝑟12 0
𝑅𝑍𝑌 = [ 𝑟21 𝑟22 0]
𝑟31 𝑟32 1

Note that the matrix is now 3 × 3, as we have 3 axes. Also, I have given you the third column,
which is going to be just 𝑘̂, as this reflection doesn’t affect anything in the Z-axis. For the other
two columns, closely examine the other standard unit vectors.
Q3 (c): What is the reflection matrix 𝑹𝒁𝒀 ?

Q3 (d): What if we chose a different point on the same ZY plane as our origin?
Would the reflection matrix be different?

Think before you answer this one.

9
CHAPTER 4: BORING ELIMINATION

Eliminate the following system of linear equations:

𝑥 + 𝑦 + 6𝑧 = 11
𝑥 + 4𝑦 + 12𝑧 = 26
𝑥 + 3𝑦 + 12𝑧 = 23

Q4 (a): What if the value of (𝒛 + 𝒚 − 𝒙)?

Eliminate the following system of linear equations:

𝑥 + 𝑦 + 6𝑧 = 11
𝑥 + 4𝑦 + 12𝑧 = 26
𝑥 + 3𝑦 + 10𝑧 = 21

If done correctly, your elimination should end up in a matrix where the last row is all ZEROs.
Which means, the third column does not have any pivot variable. In other words, we can say that
the third variable, z is a free variable and can hold any real value, and for each value of z, we can
determine corresponding values of x and y.

Q4 (b): When 𝒛 = −𝟐, what is the value of 𝒙 𝒂𝒏𝒅 𝒚?

10

You might also like