## The Outer Product of Two Vectors

I was working with some machine learning code that required the use of the outer product of two vectors. I realized I hardly ever used an outer product in code, so I had to brush up quickly by reviewing the Wikipedia entry on the topic.

Suppose vector A = [1, 3, 5] and vector B = [4, 2]. The outer product of A and B is:

``` 4   2
12   6
20  10
```

The number of rows of the outer product is the length of A and the number of columns is the length of B. Each value in the result is a product of the two corresponding entries in A and B.

Now for the ML code I was working with, the two vectors had only 0 and 1 values, so the resulting outer product will only have 0 or 1 values. For example if A = [0, 0, 1, 1, 0, 0] and B = [0, 1, 0] then the outer product is:

```0  0  0
0  0  0
0  1  0
0  1  0
0  0  0
0  0  0
```

Kind of weird. It’s very simple but I have a hard time visualizing the outer product.

n

Advertisements
This entry was posted in Machine Learning. Bookmark the permalink.