Vectors Representation

Let's motivate the concept of vectors with an example that you may have encountered while learning mathematics in high school or college. Suppose John went to the market and bought 6 oranges and 5 apples and payed a total of 27 cents for these items. Suppose Peter went to the same market bought 2 oranges and 8 apples and payed a total of 28 cents.

To determine the price of each item, we can represent the above problem as follows:

$$ 6x + 5y = 27 $$ $$ 2x + 8y = 28 $$

where
$x$: oranges
$y$: apples

There are a few ways of solving this system of equations but determining the solution begins with representing the equations in to entities that make mathematical operations feasible. In fact, we can represent the above equation as matrices and vectors below:

$$ \begin{pmatrix} 6 & 5 \\ 2 & 8 \end{pmatrix}\begin{bmatrix} x \\y \end{bmatrix}=\begin{bmatrix} 27 \\ 28 \end{bmatrix}$$

In the above representation, the have numbers of apples and oranges are on the left side as a matrix (more on these later). They are represented as a matrix. We also have $x,y$ representing product prices for apples and oranges which are unknown and the corresponding sum of cost. These are represented as vectors.

This form of representation organizes data in a way that make it feasible to perform more complex mathematical operations such as transformations, decompositions, and optimizations. We will explore these later.

Vectors

A vector is representation of data, typically numeric, in some finite dimensional space. From the above example, we have see two vectors:

$$\begin{bmatrix} x \\y \end{bmatrix} \begin{bmatrix} 27 \\ 28 \end{bmatrix}$$

This form of representation organizes data in a way that allow for more complex mathematical operations such as transformations, decompositions, and optimisations

Vector in Numpy

We represent vectors in Numpy using numpy.array() method.

import numpy as np

sample_vect = np.array([27, 28])
sample_vect
array([27, 28])