By MCP Analytics Team | Published , updated
Upload orders to forecast customer value with BG/NBD + Gamma-Gamma, then compare with held-out history.
We email you the report link.
Free up to 10,000 rows. Encrypted in transit.
Fitting the buy-till-you-die model to your transactions...
Each customer's transaction log is reduced to the three quantities the buy-till-you-die models read: how many repeat purchases they made, how far into their history the last one fell, and how long they have been observed. BG/NBD is then fitted by maximum likelihood. It treats each customer as buying at their own latent rate while active and as able to churn permanently after any purchase, which is what lets it distinguish a customer who is quiet because they buy rarely from one who has gone. Gamma-Gamma is fitted the same way to the monetary side, blending each customer's own average transaction value with the population's. Expected future purchases multiplied by expected transaction value gives predicted lifetime value over a horizon taken from the data's own span. Every run is back-tested: the model is refit on the first 70% of the history and its predictions for the remaining 30% are compared against what actually happened, and that comparison is reported, including when it goes badly.
Use it on a non-contractual business (retail, e-commerce, marketplaces, anywhere customers can lapse silently) when you need a forward-looking number: what to pay to acquire a customer, who to spend retention budget on, or how much future revenue the current base represents.
Not for subscription or contractual businesses where churn is observed directly rather than inferred from silence: use survival analysis there. Not for pre-aggregated per-customer data, and not when you need segments to target rather than a forecast to budget against: RFM segmentation is the right tool for that and complements this one. Not a substitute for margin analysis. The value here is gross.
Built for: Growth, CRM, and finance operators who want a forward-looking value per customer
Typical data source: An order or transaction export with customer ID, transaction date, and amount
A raw transactions table, one row per purchase. For example, an order export:
Minimum 100 rows · Best with 2,000-200,000 transactions across 500+ customers spanning 12-36 months, with a healthy share of repeat buyers
The numbers below come from made-up data, made by the code on this page. They show the method. They are not output from this tool and not a finding about your data.
Question: Can a buy-till-you-die model, fitted on the first 70% of a purchase history, predict how many purchases come in the last 30%, and what does the same machinery say about the next 52 weeks?
Inputs: Simulated order history, not real data. Seed 5 makes 600 customers over 52 weeks. Each customer first buys in the first 26 weeks, buys at their own rate, may stop for good after any purchase, and has their own typical order size. Nothing here is a real revenue figure.
Method: BG/NBD and Gamma-Gamma, fitted by maximum likelihood as the page describes. Each customer is reduced to repeat purchases, the time of the last one, and time observed. BG/NBD gives expected future purchases and the chance a customer is still active. Gamma-Gamma gives expected order value. Their product is the predicted value over a horizon. The back-test fits on the first 70% of the weeks (36.4) and compares predicted with actual purchases in the last 15.6. This example illustrates the calculation. It is not a forecast of any real revenue.
Result: In the back-test the model predicted 469 purchases for the held-out weeks and 436 happened. By thirds of predicted purchases, the lowest was 38 against 38, the middle 74 against 59, and the highest 357 against 339, so it ran high overall (469 against 436), most of all in the middle third (74 against 59). After refitting on all 52 weeks, the made-up customers had a mean chance of still being active of 0.72, a mean 52-week value of 91 in made-up units, and the top 10% of customers carried 49% of the total.
Limit: The data were made by a process close to the model's own assumptions, so the fit is easier than real data would be. It does not show seasonality, price changes, discounting, margin (the value is gross), or customers whose behavior drifts. The numbers illustrate the calculation and are not a prediction for any business.
Python script (numpy and scipy only):
import numpy as np
from scipy.optimize import minimize
from scipy.special import gammaln, hyp2f1
rng = np.random.default_rng(5)
N, TOT, CAL = 600, 52.0, 36.4 # customers, weeks observed, calibration weeks (70%)
# made-up customers: own buying rate, can drop out for good after any purchase
lam = rng.gamma(0.9, 1 / 6.0, N); drop = rng.beta(0.8, 2.4, N); spend = rng.gamma(6, 1.0, N) * 9
start = rng.uniform(0, 26, N) # weeks after the start that each customer first buys
buys = []
for i in range(N):
t, ts = start[i], [start[i]]
while True:
if rng.random() < drop[i]: break
t += rng.exponential(1 / lam[i])
if t > TOT: break
ts.append(t)
buys.append((np.array(ts), rng.gamma(8, spend[i] / 8, len(ts))))
def summarize(end):
x, tx, T, m = [], [], [], []
for ts, am in buys:
keep = ts <= end
if not keep.any(): x.append(-1); tx.append(0); T.append(0); m.append(0); continue
k = keep.sum()
x.append(k - 1); tx.append(ts[keep][-1] - ts[0]); T.append(end - ts[0]); m.append(am[keep][1:].mean() if k > 1 else 0)
x, tx, T, m = map(np.array, (x, tx, T, m)); ok = x >= 0
return x[ok], tx[ok], T[ok], m[ok], ok
def nll_bgnbd(p, x, tx, T):
r, a, b, al = np.exp(p)
A1 = gammaln(r + x) - gammaln(r) + r * np.log(al)
A2 = gammaln(a + b) + gammaln(b + x) - gammaln(b) - gammaln(a + b + x)
A3 = -(r + x) * np.log(al + T)
A4 = np.log(a) - np.log(b + np.maximum(x, 1) - 1) - (r + x) * np.log(al + tx)
return -(A1 + A2 + np.logaddexp(A3, np.where(x > 0, A4, -np.inf))).sum()
def fit_bg(x, tx, T):
return np.exp(minimize(nll_bgnbd, np.log([1, 1, 1, 5]), args=(x, tx, T), method="Nelder-Mead", options={"maxiter": 4000, "xatol": 1e-5, "fatol": 1e-8}).x)
def alive(P, x, tx, T):
r, a, b, al = P
return 1 / (1 + (x > 0) * a / (b + np.maximum(x, 1) - 1) * ((al + T) / (al + tx)) ** (r + x))
def exp_buys(P, x, tx, T, t):
r, a, b, al = P
g = (a + b + x - 1) / (a - 1) * (1 - ((al + T) / (al + T + t)) ** (r + x) * hyp2f1(r + x, b + x, a + b + x - 1, t / (al + T + t)))
return g * alive(P, x, tx, T)
def fit_gg(x, m):
k = x > 0; x, m = x[k], m[k]
def nll(p):
pp, q, g = np.exp(p)
return -(gammaln(pp * x + q) - gammaln(pp * x) - gammaln(q) + q * np.log(g) + (pp * x - 1) * np.log(m) + pp * x * np.log(x) - (pp * x + q) * np.log(g + m * x)).sum()
return np.exp(minimize(nll, np.log([5, 3, 20]), method="Nelder-Mead", options={"maxiter": 4000}).x)
def exp_value(G, x, m):
# Gamma-Gamma conditional mean: the population mean p*g/(q-1) blended with this customer's observed mean m
pp, q, g = G; return ((q - 1) / (pp * x + q - 1)) * (pp * g / (q - 1)) + (pp * x / (pp * x + q - 1)) * m
# back-test: fit on the first 70% of time, predict the last 30%
x, tx, T, m, ok = summarize(CAL)
P = fit_bg(x, tx, T)
pred = exp_buys(P, x, tx, T, TOT - CAL)
actual = np.array([(ts > CAL).sum() for ts, _ in buys])[ok]
print("holdout weeks %.1f; purchases predicted %.0f, actual %d" % (TOT - CAL, pred.sum(), actual.sum()))
for name, lo, hi in [("lowest third ", 0, 1/3), ("middle third ", 1/3, 2/3), ("highest third", 2/3, 1)]:
o = np.argsort(pred); s = o[int(lo * len(o)):int(hi * len(o))]
print(" %s of predicted: predicted %.0f, actual %d" % (name, pred[s].sum(), actual[s].sum()))
# refit on everything seen, then project 52 more weeks
x, tx, T, m, ok = summarize(TOT)
P = fit_bg(x, tx, T); G = fit_gg(x, m)
pa = alive(P, x, tx, T); eb = exp_buys(P, x, tx, T, 52.0)
val = np.where(x > 0, exp_value(G, x, m), G[0] * G[2] / (G[1] - 1))
ltv = eb * val
print("illustration only: mean P(alive) %.2f, mean 52-week value %.0f, top 10%% of customers carry %.0f%% of it" % (pa.mean(), ltv.mean(), 100 * ltv[np.argsort(-ltv)[:len(ltv)//10]].sum() / ltv.sum()))
Printed output from running the code above:
holdout weeks 15.6; purchases predicted 469, actual 436
lowest third of predicted: predicted 38, actual 38
middle third of predicted: predicted 74, actual 59
highest third of predicted: predicted 357, actual 339
illustration only: mean P(alive) 0.72, mean 52-week value 91, top 10% of customers carry 49% of it
Estimate what each customer is likely to spend with you over a set period ahead, straight from your order history. Upload one row per order and the report gives each customer an expected number of future orders, a chance they are still active, and an expected value. Part of your history is held back to check the forecast, and it assumes the future looks like the past.
How predicted value is spread across your base: often heavily right-skewed, which is why an average CLV can describe few of your customers.
The customers carrying the forecast, with the probability each is still active and the two factors behind their number.
The back-test: predictions the model made for time it had never seen, plotted against what actually happened, with the perfect-prediction diagonal for reference.
The fitted parameters, their interpretable ratios, and the diagnostics, including the measured test of the monetary model's independence assumption.
Plain-English reading of the results and what to do next.
What might my customers be worth next year?
Upload an order export and map customer, date, and amount. Every customer gets an expected number of future purchases, a probability they are still active, and a predicted value over a horizon derived from your own history, plus a back-test on held-out time so you can see how closely the forecast tracked the held-out time before you spend against it.
See our FAQ for pricing, privacy and how the analysis works.
By MCP Analytics Team. Last updated 5 November 2026. Cite as: MCP Analytics Team (2026). Customer lifetime value forecast. Free tool. https://mcpanalytics.ai/free/standard_ltv. Accessed the date you used it.
Connect a source to try this method on your own numbers. Setup pages: BigCommerce, Recharge, Recurly, Shopify, Squarespace Commerce, Stripe, WooCommerce.
Your turn
Bring your own data and the question you actually need answered.
MCP AnalyticsData science by email Send us your data and your question, and we will reply. ds@mcpanalytics.ai
Tell us what went wrong, in your own words. We capture the page you're on automatically, so no need to describe where you are.