liveBook · Manning

Inner product

As explained in Statistics Every Programmer Needs

A dot product is an algebraic operation that multiplies corresponding elements of two equal-length sequences and sums the products.

An inner product, or dot product, multiplies corresponding elements of two equal-length sequences and sums the results to produce one number. In Markov analysis, multiplying a state-probability vector by a transition-probability matrix produces the probability distribution for the next period. section 11.2.2

Use the operation to:

  • Project a current distribution of state probabilities into the next period. section 11.5
  • Repeat the vector–matrix multiplication to forecast several future periods, keeping the transition matrix constant. section 11.2.2
  • Compute an equivalent two-period transition by multiplying the transition matrix by itself, then applying the result to the initial vector. section 11.2.2

Forecasting cellular-market shares

Starting with pi_0 = [0.40, 0.35, 0.20, 0.05], compute pi_1 = dot(pi_0, P) to obtain [0.394, 0.329, 0.217, 0.060]. Applying the same operation again gives period-2 shares [0.39012, 0.31454, 0.22803, 0.06731]. Computing P2 = dot(P, P) and then dot(pi_0, P2) produces the same period-2 result. section 11.2.2

>>> import numpy as np

>>> pi_0 = np.array([0.40, 0.35, 0.20, 0.05])

>>> P = np.array([
>>>     [0.85, 0.06, 0.07, 0.02],
>>>     [0.08, 0.80, 0.10, 0.02],
>>>     [0.10, 0.10, 0.75, 0.05],
>>>     [0.12, 0.10, 0.08, 0.70]
>>> ])

Shows the NumPy setup for a state-probability vector and transition matrix. section 11.2.2

How Statistics Every Programmer Needs covers it

How deep it goes
Defines the operation, explains its Markov interpretation, and demonstrates repeated and direct two-period calculations.
Examples
Demonstrates cellular-market share forecasts across periods using NumPy vectors and transition matrices.
What it assumes
Assumes equal-length numeric sequences and introduces their use with state-probability vectors and transition matrices.
What you can do after
Apply it via NumPy to calculate and iterate Markov state-distribution forecasts.
How it connects
Connects dot products with matrix multiplication, transition probabilities, state probabilities, and Markov analysis.

Also explained in

Compare how 12 books explain inner product →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Every Programmer Needs. The section links point to the parts of the book it draws on.