← All simulations · Pillar 1: Numbers & pictures
Vectors as arrows
What it is
A vector is an arrow with two facts baked in: how far it reaches (its length) and
which way it points (its direction). Drawn from the origin to a point, it’s just a list
of numbers — [6, 4] means “6 across, 4 up.” That tiny idea, a list of
numbers you can picture as an arrow, is the language almost all of machine learning is written in.
Go deeper: the length (its magnitude) is the Pythagorean distance from
the origin to the tip, √(x² + y²) — the same formula as straight-line
distance. Two vectors add by lining them up tip-to-tail, which is the same as adding their x
parts and their y parts separately. You can also scale a vector (make the arrow longer or
shorter) by multiplying every number by the same amount.
Why care
Vectors are how machines hold meaning. A model’s weights are a vector; a word’s embedding is a vector; a force, a velocity, a step of gradient descent — all vectors. The two moves you practice here, adding and scaling arrows, are the exact operations a neural network does billions of times. Get arrows, and the inside of a network stops being a mystery.
The idea, intuitively
Drag the tip of the red arrow. Pull it far and the length grows; swing it around and the direction changes — one arrow, two facts. Then add a second arrow: place the gold one starting at the red one’s tip, and the green arrow shows where you end up overall. That “walk one, then the other” picture is what adding vectors means.
Peek at the data first
Each arrow is just two numbers — an x part and a y part — plus the length they imply. A list
of numbers like [6, 4] is a vector, the same shape Spectra stores a weight or an
embedding in.
Try it
Drag the white tip of arrow a to change its length and direction; the readout shows both. Tick Add a second arrow to bring in arrow b (gold), drawn from a’s tip; drag either tip and watch the green a + b arrow land exactly where walking one then the other takes you.
Where it shows up
- Neural networks. Weights are vectors; the network adds and scales them to turn inputs into outputs.
- Word embeddings. Each word becomes a vector, and similar meanings point in similar directions — you can even add them.
- Physics & graphics. Forces, velocities and motion on a screen are all arrows that add the same tip-to-tail way.
Where it came from
The arrow view of quantities grew in the 1800s from the work of William Rowan Hamilton on quaternions and Hermann Grassmann on extended algebra; Josiah Willard Gibbs and Oliver Heaviside then shaped the practical vector notation used today. It became the backbone of physics and, much later, of machine learning’s linear algebra.
Try it in code
In the Studio, the numbers behind any model — like a regressor’s weights — are a vector, one number per feature. Train a model and look at what it learned:
data = load "houses" train, test = split data, hold_out: 20% model = make_model "regressor" train_model model, on: train, predict: "price", using: ["size", "rooms"] show_model model
Check your understanding
- What two facts does a single arrow carry at once?
- Why is a vector’s length the same formula as straight-line distance?
- When you add two arrows tip-to-tail, what happens to their x parts and y parts?