Introductions to Vectors
A vector is a mathematical object that represents both direction and magnitude in space. In data science, vectors are used to describe data points, features, and model parameters such as weights.
What Is a Vector?
A vector is an ordered pair of numbers with both magnitude and direction.
v=(x,y)Vectors are often drawn as arrows from the origin to a point in space. Two vectors are considered equal if they have the same direction and length, even if they start at different locations.
The Zero Vector
The zero vector has no length and no direction. It is written as:
0=(0,0)Vector Addition and Subtraction
Addition
To add two vectors, add their corresponding components:
a+b=(a1β+b1β,a2β+b2β)You can visualize this with:
- Head-to-tail method: move the tail of one vector to the head of the other;
- Parallelogram method: both vectors start from the same point and form a parallelogram.
Subtraction
To subtract one vector from another:
aβb=(a1ββb1β,a2ββb2β)This gives a new vector pointing from the head of the second to the head of the first.
Scalar Multiplication
Multiplying a vector by a number (a scalar) stretches or flips the vector:
kβ a=(kβ a1β,kβ a2β)- If k>1, the vector is stretched in the same direction;
- If 0<k<1, the vector is shrunk;
- If k<0, it flips direction;
- If k=0, it becomes the zero vector.
Vector Magnitude (Length)
The magnitude or length of a vector is calculated with the Pythagorean theorem:
β£aβ£=a12β+a22ββThis gives the straight-line distance from the origin to the tip of the vector.
The Dot Product
The dot product combines two vectors into a single number that reflects how aligned they are:
aβ b=a1βb1β+a2βb2β- If the result is positive: the vectors point in a similar direction;
- If the result is zero: the vectors are perpendicular;
- If the result is negative: they point in opposite directions.
Example
If a=(1,2)Β Β andΒ Β b=(3,4), then:
aβ b=1β 3+2β 4=11Thanks for your feedback!
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 1.96
Introductions to Vectors
Swipe to show menu
A vector is a mathematical object that represents both direction and magnitude in space. In data science, vectors are used to describe data points, features, and model parameters such as weights.
What Is a Vector?
A vector is an ordered pair of numbers with both magnitude and direction.
v=(x,y)Vectors are often drawn as arrows from the origin to a point in space. Two vectors are considered equal if they have the same direction and length, even if they start at different locations.
The Zero Vector
The zero vector has no length and no direction. It is written as:
0=(0,0)Vector Addition and Subtraction
Addition
To add two vectors, add their corresponding components:
a+b=(a1β+b1β,a2β+b2β)You can visualize this with:
- Head-to-tail method: move the tail of one vector to the head of the other;
- Parallelogram method: both vectors start from the same point and form a parallelogram.
Subtraction
To subtract one vector from another:
aβb=(a1ββb1β,a2ββb2β)This gives a new vector pointing from the head of the second to the head of the first.
Scalar Multiplication
Multiplying a vector by a number (a scalar) stretches or flips the vector:
kβ a=(kβ a1β,kβ a2β)- If k>1, the vector is stretched in the same direction;
- If 0<k<1, the vector is shrunk;
- If k<0, it flips direction;
- If k=0, it becomes the zero vector.
Vector Magnitude (Length)
The magnitude or length of a vector is calculated with the Pythagorean theorem:
β£aβ£=a12β+a22ββThis gives the straight-line distance from the origin to the tip of the vector.
The Dot Product
The dot product combines two vectors into a single number that reflects how aligned they are:
aβ b=a1βb1β+a2βb2β- If the result is positive: the vectors point in a similar direction;
- If the result is zero: the vectors are perpendicular;
- If the result is negative: they point in opposite directions.
Example
If a=(1,2)Β Β andΒ Β b=(3,4), then:
aβ b=1β 3+2β 4=11Thanks for your feedback!