Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Open In Colab Binder

Starting from a Question

Suppose you want to record “the ratings that 10 users give to 5 movies.” There are two quite different ways to do it:

Approach A: record only the average rating of each user and the average rating of each movie. That is 10+5=1510 + 5 = 15 numbers in all.

Approach B: record the rating that each user gives to each movie. That is 10×5=5010 \times 5 = 50 numbers in all.

Approach A uses the direct-sum structure U⊕MU \oplus M; Approach B uses the tensor-product structure U⊗MU \otimes M.

The two store different amounts of data, and they can answer different questions:

QuestionDirect sum U⊕MU \oplus MTensor product U⊗MU \otimes M
What is Xiaoming’s average rating?✓✓
What is the average rating of Titanic?✓✓
What rating did Xiaoming give Titanic?✗✓
Do action fans and romance fans rate the same movie equally high?✗✓

The price of the direct-sum structure is that it implicitly assumes that every user’s preference distribution has the same shape, differing only in its overall level. In other words, “who is watching” does not affect the ranking of “which movies are popular.” In reality this assumption often fails.

Mathematical Structure

Let the user space UU have dimension mm and the movie space MM have dimension nn. The dimensions of the two ways of combining them are

dim⁡(U⊕M)=m+n(direct sum, concatenation)\dim(U \oplus M) = m + n \qquad \text{(direct sum, concatenation)}
dim⁡(U⊗M)=m×n(tensor product, all combinations)\dim(U \otimes M) = m \times n \qquad \text{(tensor product, all combinations)}

Through two concrete scenarios (movie recommendation and a casino roulette wheel), this experiment uses actual data to show which information each structure keeps and which it loses.

A note on the language of probability: The second half of the experiment uses “marginal distributions” and “conditional distributions” to describe precisely how the two structures differ. If you are not yet familiar with these notions, just remember: the direct sum corresponds to “computing each mean separately,” the tensor product corresponds to “keeping the actual value of every combination,” and the language of probability is only a precise way of saying the same thing.

Through two concrete scenarios, this experiment shows which information the “direct sum” and the “tensor product” keep, and which they lose, when they serve as data compression structures.

StructureMathematical formInformation keptLanguage of probability
Direct sum U⊕MU \oplus MSum of marginalsP(ui)P(u_i) and P(mj)P(m_j) (each separately)Marginal distributions
Tensor product U⊗MU \otimes MComplete interaction matrixP(ui,mj)P(u_i, m_j) (joint)Conditional distributions P(mj∣ui)P(m_j \mid u_i)

The essential difference between the two:

P(ui, mj)=P(ui)⋅P(mj)⏟direct sum: independence assumptionvsP(mj∣ui)≠P(mj)⏟tensor product: conditional dependence\underbrace{P(u_i,\, m_j) = P(u_i)\cdot P(m_j)}_{\text{direct sum: independence assumption}} \qquad\text{vs}\qquad \underbrace{P(m_j \mid u_i) \neq P(m_j)}_{\text{tensor product: conditional dependence}}

Scenario 1: A Movie Recommender System

How the Data Are Generated

We set up 10 users (5 action fans and 5 romance fans) and 5 movies (2 action, 2 romance, and 1 mixed).

Each user is represented by a two-dimensional preference vector ui=(ai,ri)⊤\mathbf{u}_i = (a_i, r_i)^\top (aia_i = preference for action, rir_i = preference for romance), and each movie by mj=(Aj,Rj)⊤\mathbf{m}_j = (A_j, R_j)^\top, its genre weights.

The true rating is determined by the inner product, with normal noise added:

rij=5⋅(ui⋅mj)+ε,ε∼N(0, 0.42)r_{ij} = 5 \cdot (\mathbf{u}_i \cdot \mathbf{m}_j) + \varepsilon, \quad \varepsilon \sim \mathcal{N}(0,\, 0.4^2)

This means that action fans naturally give action movies high ratings and romance movies low ratings, and vice versa. The data really do contain an interaction effect, so we can expect a part that the direct-sum model cannot capture.

Each user–movie combination produces 2 records, 100 records in all.

A. Shuffled vs. Sorted: The Same Data from Two Points of View

The figure below shows two visualizations of the same raw log of records: the left panel lists the users in a randomly shuffled order (simulating the order of the raw records, with action fans and romance fans mixed together), and the right panel re-sorts them by user type (action fans on top, romance fans at the bottom).

The data do not change at all; only the order of the rows differs. Yet how visible the pattern is differs greatly.

B. The Direct-Sum Structure: Summing Marginals

The direct-sum model keeps only two sets of marginal statistics:

rˉi⋅=15∑jrij(user mean)rˉ⋅j=110∑irij(movie mean)\bar{r}_{i\cdot} = \frac{1}{5}\sum_j r_{ij} \quad(\text{user mean}) \qquad \bar{r}_{\cdot j} = \frac{1}{10}\sum_i r_{ij} \quad(\text{movie mean})

The prediction matrix is built from outer products, and its rank is at most 2 (in practice close to rank 1):

R^=rˉ⋅1⊤+1 rˉ⊤−rˉ 11⊤\hat{R} = \bar{\mathbf{r}}_{\cdot} \mathbf{1}^\top + \mathbf{1}\,\bar{\mathbf{r}}^\top - \bar{r}\, \mathbf{1}\mathbf{1}^\top

C. The Tensor-Product Structure: Keeping the Joint Information

The tensor-product matrix records rijr_{ij} directly (the observed mean for each user–movie pair). From it we can read off the conditional distribution P(high rating∣ui,mj)P(\text{high rating} \mid u_i, m_j), and also whether, once we fix the user, the shape of the rating curve over the movies differs from person to person. This is precisely what the direct-sum structure cannot express.

Scenario 2: Detecting Collusion at a Casino Roulette Wheel

How the Data Are Generated

A simplified roulette wheel has 6 numbers (0–5). In each round the player bets on one number, the wheel produces one number, and a hit is paid at 5 to 1. This is exactly the fair payout with zero house edge: if everyone plays honestly, the house neither gains nor loses.

The tensor product in this scenario has two axes:

  • the number the player bets on (the player’s betting choice)

  • the number the wheel lands on (the casino’s actual outcome)

On a fair wheel these two should be statistically independent: which number you bet on does not affect where the wheel stops. But this casino has an insider who has rigged the game. In about 26% of the rounds (the collusion rounds), a colluding player bets on one of two “signal numbers” {1,4}\{1, 4\}, and at the same time the wheel is steered to the same number, so the bet and the outcome are locked together.

The clever part is this: to avoid being caught by a “marginal audit,” in the remaining honest rounds the insider deliberately suppresses the signal numbers: players bet less on {1,4}\{1,4\}, and the wheel lands less often on {1,4}\{1,4\}. Once the surge in the collusion rounds and the dip in the honest rounds offset each other, the marginal distributions of both the bets and the outcomes stay close to uniform, and the table looks no different from any ordinary one.

The data-generation logic:

  1. With probability ε=0.26\varepsilon = 0.26, play a collusion round: bet == outcome == one of the signal numbers;

  2. With probability 1−ε1-\varepsilon, play an honest round: as cover, the player and the wheel sample independently from a distribution that “suppresses the signal numbers”;

  3. A hit is paid at 5 to 1; on a miss the house collects the stake.

The question: if risk control watches only the two marginal distributions (“which numbers players like to bet on” and “which numbers the wheel often lands on”), can it catch the collusion? Or is it impossible without looking at the joint distribution (the tensor product)?

An intuition trap: Thanks to the cover, both marginal distributions look close to uniform, and any audit that checks only “how often each single number appears” will let the table pass. The hard evidence of collusion lies in no single marginal; it lies in the joint phenomenon that “the bet and the outcome are locked to the same number,” which exists only in the tensor-product structure.

Summary

Direct sum U⊕MU \oplus MTensor product U⊗MU \otimes M
Information keptMarginal distributions P(ui)P(u_i), P(mj)P(m_j)Joint distribution P(ui,mj)P(u_i, m_j)
Implicit assumptionUser and movie preferences are statistically independentNo independence assumption
Rank of the matrix≤2\leq 2≤min⁡(∣U∣,∣M∣)\leq \min(|U|, |M|)
When they agreeP(ui,mj)=P(ui)⋅P(mj)P(u_i, m_j) = P(u_i)\cdot P(m_j) (that is, no interaction effect)—
Casino exampleKnows only “which numbers players like to bet on” and “which numbers the wheel often lands on”Knows “whether the bet and the outcome are locked together” (the evidence of collusion)

The rows of the direct-sum prediction matrix (each with a fixed user) differ from one another only by a constant offset, and the curves have exactly the same shape. The tensor product keeps each user’s personalized distribution, whose shape differs from person to person.


Preview of Chapter 11. Tensor-product matrices are often redundant: “the rows of all the action fans are similar” means that the effective dimension of the matrix is far smaller than min⁡(∣U∣,∣M∣)\min(|U|, |M|). The SVD (singular value decomposition) is precisely the tool for measuring this redundancy: it decomposes the tensor-product matrix into a sum of rank-one matrices (each a multiplicative pure tensor uv⊤\mathbf{u}\mathbf{v}^\top, not the additive direct-sum structure of Part B), ordered by importance, which makes low-rank approximation and data compression possible.

Exercises