Course Content

Mathematics for Data Analysis and Modeling

## Mathematics for Data Analysis and Modeling

# Vectors and Matrices

## What is vector?

A **vector** is a mathematical object representing a quantity with both magnitude and direction. To understand the essence of what a vector is, let's first understand what is a single number.**A single number** is a simple quantitative characteristic of some property that describes its magnitude. At the same time, a vector is a collection of such characteristics and can be used to describe complex objects and processes that a single number cannot describe.

So the vector can be interpreted as an **ordered list of numbers**. These numbers are also called **coordinates**.

Vectors can describe velocity, force, colors, complex data structures, etc. Also, with the help of vectors, the **position of a point in space is usually set**.

## Example: determining the position of a point in space

We can see 4 different arrows: each has the **same length but different directions**. As a result, we can't describe the arrow using only magnitude as a single number - we have to use a vector to provide additional information about the direction of the arrow.

## Example: Data representation for machine learning models

Data for machine learning models are also represented using vectors:

We can see that information about each Iris flower is stored as a **vector with 4 coordinates**. Each coordinate represents a particular feature of the flower: length/ width of a sepal/petal.

Obviously, if we use a single number instead of a vector, we will not be able to provide enough information about the characteristics of one particular plant.

## What is matrix?

Another important mathematical object is a **matrix** - a rectangular array of numbers, symbols, or expressions arranged in rows and columns.

Matrices are used to represent and manipulate **linear transformations**, **systems of linear equations**, and other mathematical operations. We can interpret a matrix as a vector whose coordinates are vectors too.
Matrices are commonly used to describe and model different processes.

## Image representation using matrix

Each number in the matrix represents a pixel's intensity or brightness value in the greyscale image.

## Figure manipulations

We can also provide different manipulations with figures using matrices. For example, we can rotate a figure using **matrix multiplication** (we will consider this operation in more detail in the next section):

We used a specific **rotation matrix** and applied it to our figure. This matrix determines the way we rotate our figure. You can change the `angle_deg`

variable in the code above and look at the result of rotation.

As a result, we got the same figure with the same characteristics but rotated by 45 degrees counterclockwise.

Note

There are many other ways to use vectors and matrices in real-life tasks. Enumerating them will take a long time, so we will not do it in this course.

Everything was clear?