A vector is an array of scalar numbers. We can identify each individual number by its index in that ordering. Typically, we give vectors lowercase names in bold typeface, such as $\mathbf{x}$.

Individual elements in the vector can be identified by the name in italics with a subscript indicating the element position. Vectors are conventionally $1$-indexed and are typically assumed to be column vectors.

For convenience, we commonly represent a vector as the transpose of a row vector.

We can represent a vector as a list in Python.

```
x = [7, 4, 3, 2]
# Python is zero-indexed so x[2] will give the third element in the vector
print("Third element in vector x is {}".format(x[2]))
print("x is of type {}".format(type(x)))
```

```
Third element in vector x is 3
x is of type <class 'list'>
```

We can also represent a vector as a NumPy array. NumPy features a powerful $n$-dimensional array object and many useful tools and functions used in linear algebra.

```
x = np.array([7, 4, 3, 2])
print("Third element in vector x is {}. x is of type {}".format(x[2], type(x)))
print("x is of type {}".format(type(x)))
# Using NumPy arrays gives us access to more specialised functions
print("x has shape {}".format(x.shape))
```

```
Third element in vector x is 3. x is of type <class 'numpy.ndarray'>
x is of type <class 'numpy.ndarray'>
x has shape (4,)
```

Source: https://github.com/maxbartolo/ml-index/blob/master/01-basic-math/01-linear-algebra/02-vectors.ipynb

## Share this post

Twitter

Facebook

Reddit

LinkedIn

Google+

StumbleUpon

Pinterest

Email