Skip to Content
Mathematical Background

Last Updated: 3/10/2026


Mathematical Background

Introduction

The TFT Rolling Odds Calculator uses Markov Chains to model the probability of finding units. This mathematical approach provides exact probabilities rather than approximations, accounting for the dynamic nature of the shared unit pool.

Why Markov Chains?

The Challenge

Calculating rolling probabilities in TFT is complex because:

  1. Dynamic Pool: Each time you hit a unit, it’s removed from the pool, changing future probabilities
  2. Multiple Shops: A single reroll gives you 5 shops, creating many possible outcomes
  3. Headliners: Special shops that give 3 copies instead of 1
  4. State Dependencies: The probability of hitting a unit depends on how many you’ve already found

Traditional Approach (Doesn’t Work Well)

A naive approach might try:

P(hit unit) = P(roll correct cost) × (units_left / pool_size)

But this fails because:

  • Probabilities change as you roll
  • Multiple paths lead to the same outcome
  • Combinatorial explosion makes brute force impractical

Markov Chain Solution

Markov Chains elegantly solve this by:

  • Representing each possible state (0 units found, 1 unit found, etc.)
  • Defining transition probabilities between states
  • Using matrix mathematics to compute final probabilities

Core Concepts

States

A state represents how many copies of your desired unit you’ve found:

  • State 0: Found 0 copies
  • State 1: Found 1 copy
  • State 2: Found 2 copies
  • State 9+: Found 9 or more copies

Transition Probability

The probability of moving from one state to another in a single shop:

P(transition from state i to state i+1) = P(hit unit | currently have i copies)

This is calculated as:

P(hit) = P(roll correct cost) × (copies_remaining / pool_size_remaining)

Where:

  • copies_remaining = total_copies - copies_already_out - i
  • pool_size_remaining = total_pool_size - total_units_out - i

Transition Matrix

A transition matrix M represents all possible state transitions:

M = [ [p₀₀, p₀₁, 0, 0, ...], [0, p₁₁, p₁₂, 0, ...], [0, 0, p₂₂, p₂₃, ...], ... ]

Where:

  • p_ii = probability of staying in state i (not hitting the unit)
  • p_i(i+1) = probability of moving from state i to i+1 (hitting the unit)
  • All other entries are 0 (you can’t go backwards or skip states)

Example Walkthrough

Setup

Let’s find the probability of getting Yuumi (2-cost) after spending 4 gold (2 rerolls = 10 shops).

Parameters:

  • Level: 6
  • Unit cost: 2
  • Copies already out: 5
  • Total 2-costs out: 40
  • Gold to spend: 4

Step 1: Calculate Base Probability

At level 6, the probability of rolling a 2-cost is 40% (from game data).

total_2cost_units = 20 (bag size) × 13 (distinct champions) = 260 yuumis_remaining = 20 - 5 = 15 pool_remaining = 260 - 40 = 220 P(hit Yuumi | 0 found) = 0.40 × (15/220) = 0.0273 (2.73%)

Step 2: Build Transition Matrix (3×3 for simplicity)

For states 0, 1, 2:

M = [ [0.9727, 0.0273, 0 ], # From 0 units [0, 0.9726, 0.0274], # From 1 unit [0, 0, 1 ] # From 2+ units (absorbing state) ]

Note: Probabilities change slightly as units are removed.

Step 3: Raise Matrix to Power

4 gold = 2 rerolls = 10 shops, so we compute M¹⁰:

M¹⁰ = M × M × M × M × M × M × M × M × M × M

Using matrix multiplication:

M¹⁰ = [ [0.7621, 0.2142, 0.0237], [0, 0.7613, 0.2387], [0, 0, 1 ] ]

Step 4: Read Results

Starting from state 0 (no units), read the first row:

  • 76.21% chance of ending with 0 units
  • 21.42% chance of ending with 1 unit
  • 2.37% chance of ending with 2 units

Cumulative probabilities (at least X):

  • At least 1: 23.79%
  • At least 2: 2.37%

Mathematical Properties

Matrix Multiplication

When we multiply transition matrices:

M² = M × M

The entry M²[i][j] represents: “Probability of going from state i to state j in exactly 2 steps.”

This works because matrix multiplication sums over all possible intermediate paths:

M²[i][j] = Σₖ M[i][k] × M[k][j]

This naturally accounts for all possible sequences of hits and misses.

Why Powers?

For n shops, we compute Mⁿ because:

  • M¹ = probability after 1 shop
  • M² = probability after 2 shops
  • M³ = probability after 3 shops
  • Mⁿ = probability after n shops

Absorbing States

State 9+ is an absorbing state: once you reach it, you stay there (probability 1).

This is represented by the last row/column:

M[9][9] = 1 M[9][j] = 0 for all j ≠ 9

Handling Headliners

The Headliner Problem

Headliners complicate the model because:

  1. They appear with a different probability than normal shops
  2. They give 3 copies instead of 1
  3. After getting a headliner, the next 4 shops can’t be headliners

Solution: Law of Total Probability

We calculate separate transition matrices for each possible “headliner scenario”:

  1. No headliner: Roll all shops normally
  2. Headliner on shop 1: Get headliner first, then normal shops
  3. Headliner on shop 2: Normal shop, then headliner, then normal shops
  4. Headliner on shop 3: Two normal, then headliner, then normal shops

For each scenario:

P(scenario i) = P(headliner on shop i) × P(no headliner before shop i)

Headliner Transition Matrix

When a headliner appears, we use a special transition matrix that jumps 3 states:

H = [ [0, 0, 0, 1, 0, 0, ...], # 0 → 3 units [0, 0, 0, 0, 1, 0, ...], # 1 → 4 units [0, 0, 0, 0, 0, 1, ...], # 2 → 5 units ... ]

Combined Calculation

Final_Matrix = Σᵢ P(headliner on shop i) × [Normal_Matrix^(i-1) × H × Normal_Matrix^(remaining_shops)] + P(no headliner) × Normal_Matrix^(all_shops)

Implementation Details

Transition Probability Formula

From the code:

function getTransitionProb(cost, lvl, a, b) { const howManyLeft = Math.max(0, totalUnits[cost - 1] - a); const poolSize = totalUnits[cost - 1] * distinctChamps[cost - 1] - b; return getCostProb(lvl, cost) * (howManyLeft / poolSize); }

Where:

  • cost: Unit cost tier (1-5)
  • lvl: Player level (1-11)
  • a: Copies of specific unit already out
  • b: Total units of this cost already out
  • getCostProb(lvl, cost): Returns probability of rolling this cost at this level

Matrix Construction

function getTransitionMatrix(cost, lvl, a, b) { const mat = []; for (let i = 0; i < 10; i++) { const newRow = []; const p = getTransitionProb(cost, lvl, a+i, b+i); for (let j = 0; j < 10; j++) { if (i == 9 && j == 9) { newRow.push(1); // Absorbing state } else if (j == i) { newRow.push(1 - p); // Stay in state } else if (j == i + 1) { newRow.push(p); // Transition to next state } else { newRow.push(0); // Impossible transition } } mat.push(newRow); } return mat; }

Matrix Power Calculation

function power(a, n) { var newmat = a; for (let i = 0; i < n-1; i++) { newmat = multiply(newmat, a); } return newmat; }

Note: This uses repeated multiplication. For large n, more efficient algorithms (like exponentiation by squaring) could be used.

Advantages of This Approach

1. Exact Results

Unlike simulation or approximation, Markov Chains give exact probabilities.

2. Efficient Computation

Matrix exponentiation is fast, even for many shops (O(s³ × log n) with optimizations, where s is number of states).

3. Handles Complexity

Naturally accounts for:

  • Changing probabilities as pool depletes
  • Multiple paths to same outcome
  • Headliner mechanics

4. Extensible

Easy to modify for:

  • Different game modes
  • New mechanics
  • Alternative scenarios

Limitations

1. Assumes Independence

The model assumes other players’ actions don’t change during your roll. In reality, they might roll simultaneously.

2. Fixed Pool Estimate

Requires estimating how many units are out. This is approximate in real games.

3. Computational Limits

Very large numbers of shops (100+ gold) may have precision issues with repeated matrix multiplication.

4. No Adaptation

Doesn’t account for decision-making during rolling (e.g., “if I hit 2, I’ll stop”).

Further Reading

Markov Chain Theory

  • Markov Property: Future states depend only on current state, not history
  • Stochastic Matrices: Rows sum to 1 (probability distributions)
  • Absorbing Chains: Chains with terminal states
  • Steady State: Long-term probability distributions
  • Hypergeometric Distribution: Alternative approach for single-roll probabilities
  • Negative Binomial Distribution: For “rolls until X hits”
  • Monte Carlo Simulation: Alternative computational approach

Conclusion

The Markov Chain approach elegantly solves the complex probability problem of TFT rolling. By representing the process as state transitions and using matrix mathematics, we can compute exact probabilities efficiently, even with complications like headliners and pool depletion.

This mathematical foundation makes the calculator both accurate and fast, providing players with reliable information for strategic decision-making.

Next Steps