MATHEMATICS FOR AI • LESSON 2

Vectors

A vector is an ordered collection of numbers. Vectors allow us to represent several related values together, which makes them extremely important in AI and machine learning.

CORE IDEA

A vector is a collection of numbers stored together.

A scalar represents one numerical value. A vector represents multiple related numerical values as one ordered group.

01

What Is a Vector?

A vector is simply a collection of numbers arranged in a specific order.

For example:

[10, 20, 30]

This is a vector because it contains three numbers that are grouped together.

Each number inside a vector is called a component or element.

Vector

[10, 20, 30]
  ↑   ↑   ↑
  |   |   |
  |   |   └── Component 3
  |   └────── Component 2
  └────────── Component 1
02

Scalar vs Vector

The easiest way to understand a vector is to compare it with a scalar.

Scalar

5


Vector

[5, 10, 15]

A scalar contains only one number.

A vector contains multiple numbers that are treated as one ordered collection.

This difference is very important in linear algebra. Scalars and vectors are different mathematical objects.

03

What Do the Numbers in a Vector Mean?

The numbers inside a vector usually represent different pieces of related information.

For example, imagine we want to describe a student using three values:

Age       = 25
Study     = 5 hours
Score     = 80

We can put these values into one vector:

[25, 5, 80]

Here, the first number represents age, the second represents study hours, and the third represents the exam score.

The order matters. If we change the order, the meaning changes too.

04

Vector Components

Every number inside a vector has a position. That position is important because it tells us what the number represents.

x = [10, 20, 30]

First component  = 10
Second component = 20
Third component  = 30

We can also refer to components using an index. In many programming languages, indexing starts from zero.

x = [10, 20, 30]

x[0] = 10
x[1] = 20
x[2] = 30

So, a vector is not just a random list of numbers. The position of each number gives it meaning.

05

How Do We Write a Vector?

A vector is commonly written using square brackets.

[2, 4, 6]

[10, 20]

[1, 5, 8, 12]

We can give a vector a name as well.

x = [2, 4, 6]

Here, x is the name of the vector and [2, 4, 6] contains its values.

06

Vectors in AI

Vectors are extremely important in AI because real-world information often contains many values.

For example, a house could be represented using:

Size       = 1500 sq ft
Bedrooms   = 3
Bathrooms  = 2
Age        = 10 years

These values can be represented as one vector:

[1500, 3, 2, 10]

A machine learning model can then work with this vector when trying to predict something, such as the price of the house.

07

Vectors and Machine Learning Features

In machine learning, the individual values used to describe something are often called features.

For example, suppose we want to predict whether a customer is likely to buy a product.

Age       = 30
Income    = 50000
Visits    = 8
Purchases = 3

These features can be represented as a vector:

[30, 50000, 8, 3]

The vector gives the machine learning model a numerical representation of the customer.

This is one of the fundamental ways data is represented inside machine learning systems.

08

How Vectors Fit Into Linear Algebra

Scalars, vectors, and matrices are closely connected.

Scalar
   ↓
One number

Vector
   ↓
Collection of numbers

Matrix
   ↓
Numbers arranged in rows and columns

A vector is therefore the next step after understanding scalars.

Once we understand vectors, we can learn how to add them, multiply them, calculate dot products, and eventually work with matrices.

WHAT TO REMEMBER

A vector is an ordered collection of numbers.

Each number in a vector is called a component. The order of the components matters because each position can represent different information. Vectors are used heavily in AI and machine learning to represent data and features.