Skip to content
Marketing Measurement Science

Huff Model

Estimate how customers at each origin distribute purchases among the stores in their choice set.

Store choice probabilities

For a customer at origin i, the Huff model divides store j’s attractiveness adjusted for distance by the sum across eligible stores.

Pij = (Ajα / Dijβ) ÷ Σk (Akα / Dikβ)

In this example, A is store size and D is distance. The exponent α controls the importance of size. A larger positive β discounts distant stores more sharply.

Review Reading Regressions for help interpreting the coefficients.

Fit size and distance weights

This example trains on trips with exactly two available stores. Provide one row per trip in paired_store_choices with chosen_a (0 or 1), size_a, size_b, distance_a_km, and distance_b_km. The log odds of choosing A over B are the differences in their log utilities. The fitted size coefficient is α and the negative of the distance coefficient is β.

CREATE OR REPLACE MODEL `project.dataset.huff_model` OPTIONS ( MODEL_TYPE = 'LOGISTIC_REG', INPUT_LABEL_COLS = ['chosen_a'], FIT_INTERCEPT = FALSE, DATA_SPLIT_METHOD = 'NO_SPLIT' ) AS SELECT chosen_a, LN(size_a) - LN(size_b) AS log_size_ratio, LN(GREATEST(distance_a_km, 0.1)) - LN(GREATEST(distance_b_km, 0.1)) AS log_distance_ratio FROM `project.dataset.paired_store_choices` WHERE chosen_a IN (0, 1) AND size_a > 0 AND size_b > 0 AND distance_a_km >= 0 AND distance_b_km >= 0;

Predict shares with the fitted weights

The prediction query expects one row per eligible origin–store pair in store_choice_inputs, with origin_id, store_id, square_footage, distance_km, and spend_potential. Use the same distance measure and units in both queries. Straight-line distance and driving time measure different things and call for separate fits. The 0.1 km floor keeps coincident points finite.

WITH coefficients AS ( SELECT MAX(IF(processed_input = 'log_size_ratio', weight, NULL)) AS alpha, -MAX(IF(processed_input = 'log_distance_ratio', weight, NULL)) AS beta FROM ML.WEIGHTS(MODEL `project.dataset.huff_model`, STRUCT(FALSE AS standardize)) ), scores AS ( SELECT origin_id, store_id, spend_potential, alpha * LN(square_footage) - beta * LN(GREATEST(distance_km, 0.1)) AS log_utility FROM `project.dataset.store_choice_inputs` CROSS JOIN coefficients WHERE square_footage > 0 AND distance_km >= 0 ), utilities AS ( SELECT *, EXP(log_utility - MAX(log_utility) OVER (PARTITION BY origin_id)) AS utility FROM scores ), shares AS ( SELECT origin_id, store_id, spend_potential, SAFE_DIVIDE(utility, SUM(utility) OVER (PARTITION BY origin_id)) AS choice_probability FROM utilities ) SELECT origin_id, store_id, choice_probability, spend_potential * choice_probability AS expected_spend FROM shares;

Validate the coefficients and predicted shares on held-out trips. Applying a two-store fit to larger choice sets assumes the same utilities and that relative odds for two stores stay stable when alternatives are added. Expected spend also assumes the input spend is allocated among the listed stores.

Interactive Huff simulator

All values below are computed live using the Huff formula from the Model and Formula tab. Adjust stores, distances, and parameters to see market shares and revenue predictions update in real time.

Distance: This example uses entered straight-line distances. Use the same distance measure when fitting and applying the model.

Model parameters

2.0
1.0

Stores

StoreSq 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

Store 104 Revenue—
Comp A Revenue—
Comp B Revenue—
Store 104 Market Share—

ZIP code probability breakdown

Zip Spend ($k) P(Store 104) P(Comp A) P(Comp B) Rev → 104
Formula applied:
Pij = (Sizejα / Distijβ) ÷ Σk(Sizekα / Distikβ)  |  Revenueij = Pij × Spendi