From algebraic theory to BigQuery execution — estimate the probability a customer travels to each store, and compute share of wallet by geography.
At its Core: Just Algebra
The Huff Model is not a “black box.” It calculates the probability that a customer at an origin (i) (like a home or zip code) will travel to a specific destination (j) (a store).
The Variables
If you have the data (origins and destinations), you don’t need expensive proprietary tools. You can run the math directly in BigQuery, Snowflake, or Redshift.
The Workflow
Calibrate (BQML)
Don’t guess the Beta. Use logistic regression to find it. BQML effectively “self-corrects” for the difference between straight-line distance and drive time.
The Matrix (Cross Join)
Connect every zip code to every store using ST_DISTANCE. Optimize using ST_DWITHIN (e.g., limit to 50km).
Calculate Probability
Use window functions to sum the total utility per zip code.
Step 1: Auto-Calibration with BQML
Find the exact Beta (β) and Alpha (α) from your sales history.
Step 2: The Prediction Query
Apply the weights found above to predict future scenarios.
Interactive Huff Simulator
All values below are computed live using the Huff formula from Tab 1. Adjust stores, distances, and parameters to see market shares and revenue predictions update in real time.
ST_DISTANCE() for geodesic straight-line distance, or integrate with the Google Maps Distance Matrix API / OSRM for drive-time distances. When you calibrate β using BQML (see Tab 2), the model automatically compensates for the difference between straight-line and actual driving distance.
Model Parameters
Stores
| Store | Sq Ft |
|---|---|
| Our Store (104) | |
| Competitor A | |
| Competitor B |
Distance Matrix (km) & Spend Potential
Enter straight-line distance from each zip code to each store. All fields are editable.
| Zip | Spend ($k) | → Store 104 | → Comp A | → Comp B |
|---|---|---|---|---|
| 90210 | ||||
| 90211 | ||||
| 90212 | ||||
| 90213 | ||||
| 90214 |
Computed Results
Zip Code Probability Breakdown
| Zip | Spend ($k) | P(Store 104) | P(Comp A) | P(Comp B) | Rev → 104 |
|---|
Pij = (Sizejα / Distijβ) ÷ Σk(Sizekα / Distikβ) | Revenueij = Pij × Spendi