Skip to content
  • There are no suggestions because the search field is empty.

Technical Documentation: Repurchase Probability and Predicted Customer Lifetime Value

Modified BG/NBD calculation used in Raptor

This article explains in technical detail how Raptor calculates:

  • Repurchase probability

  • Predicted number of orders next 365 days

  • Predicted future value next 365 days

  • Predicted Customer Lifetime Value.

It is intended for readers who want to understand the full calculation from historical orders to final customer value. For a practical introduction, see AI Models: Introduction to the Customer Lifetime Value Model.

Data sensitivity note: this article does not contain customer-specific data, customer names, segment names, customer counts, transaction totals, fitted production parameters, or any customer-specific examples. All numeric examples and figures are illustrative and synthetic.

At a high level, the final value calculation is:

Predicted Customer Lifetime Value =
Historic value all time + Predicted future value next 365 days

where:

Predicted future value next 365 days =
Predicted number of orders next 365 days × Average order value

The statistically complex part is therefore the calculation of Repurchase probability and Predicted number of orders next 365 days. Both are produced by the Modified BG/NBD model.


1. Customer-level input data

The model starts from historical orders. Before fitting or scoring the model, the transaction history is summarised per customer.

The key model inputs are:

Model symbol Meaning Related Raptor KPI
x Repeat purchase frequency Related to Number of orders
tx Recency: time from first order to latest order Derived from Days since first order and Days since last order
T Customer age: time from first order to the calculation date Days since first order
t Future prediction horizon 365 days

The relationship between T, tx, and Days since last order is:

t_x = T − Days since last order

For example, if a customer placed their first order 400 days ago and their latest order 40 days ago, then T = 400 and t_x = 360. The same logic applies to every customer using that customer's own order history.

Frequency in BG/NBD terminology

In BG/NBD terminology, frequency means repeat purchase frequency:

x = number of purchase events after the first purchase event

So if a customer has placed 5 purchase events in total, the model frequency is x = 4. This is why x is related to, but not always identical to, the Raptor KPI Number of orders. The same definition of a purchase event must be used consistently when fitting the model and when making predictions.


2. What the Modified BG/NBD model assumes

Raptor uses the Modified BG/NBD model to model repeat purchases in a non-contractual customer relationship. A non-contractual relationship means that customers do not explicitly cancel. If a customer has not bought recently, we do not know whether the customer has churned or is simply waiting longer than usual before the next purchase. The model handles this uncertainty statistically.

It assumes that each customer has two hidden characteristics:

Hidden variable Meaning
λ The customer's personal purchase rate while active
p The customer's probability of becoming inactive

These values are not observed directly. They are inferred from the customer's historical purchase pattern and from the purchase patterns observed across the full customer base.

2.1 Customers buy according to a personal purchase rate

While a customer is active, purchases are assumed to follow a Poisson process with rate λ. This means that, for an active customer, the expected number of purchases increases with time:

Expected purchases over time period τ = λτ

If time is measured in days, then λ is the expected number of purchases per day while the customer is active. A customer with a high λ buys often. A customer with a low λ buys rarely. In business terms, this is related to the customer's Average days between orders.

2.2 Purchase rates differ across customers

Not all customers have the same purchase rate. The model assumes that customer-level purchase rates vary across the customer base according to a gamma distribution:

λ ~ Gamma(r, α)

The fitted parameters r and α describe how purchase frequency varies across customers. Using the rate-parameter version of the gamma distribution, the average purchase rate in the customer base is:

E[λ] = r / α

2.3 Customers can become inactive

The model assumes that customers may become inactive. In the Modified BG/NBD model, a customer can become inactive at the beginning of the customer relationship, and after each purchase. This modification is important because it allows one-time customers to have a Repurchase probability below 100%, which is often more intuitive in ecommerce settings than assuming a one-time buyer is definitely still active.

2.4 Dropout probabilities differ across customers

Not all customers have the same probability of becoming inactive. The model assumes that customer-level dropout probabilities vary across the customer base according to a beta distribution:

p ~ Beta(a, b)

The fitted parameters a and b describe how likely customers are to become inactive. The average dropout probability in the customer base is:

E[p] = a / (a + b)


3. Fitting the model

The model is fitted across the customer base. For each customer, we observe x, tx, and T, but we do not observe the customer's true personal values of λ and p.

The fitting process estimates the four population-level parameters: r, α, a, b. These parameters describe the overall distribution of purchase rates and dropout probabilities in the customer base.

The model is fitted by maximum likelihood — it chooses the values of r, α, a, and b that make the observed customer purchase histories most likely under the Modified BG/NBD assumptions.

3.1 The likelihood used by ModifiedBetaGeoFitter

For one customer with purchase history (x, tx, T), the implementation calculates the following log-likelihood components:

A1 = log Γ(r + x) − log Γ(r) + r log(α)
A2 = log Γ(a + b) + log Γ(b + x + 1) − log Γ(b) − log Γ(a + b + x + 1)
A3 = −(r + x) log(α + T)
A4 = log(a) − log(b + x) + (r + x) [log(α + T) − log(α + t_x)]

The customer-level log-likelihood is then:

ℓᵢ = A1 + A2 + A3 + log(1 + exp(A4))

Across all customers, the fitting process maximises the sum of these log-likelihoods. If a regularisation penalty is configured, it is added to the negative log-likelihood to make the fitted parameters more stable.

Once the model has been fitted, every customer can be scored using x, tx, T, r, α, a, b. These values are enough to calculate both Repurchase probability and Predicted number of orders next 365 days.

4. How Repurchase probability is calculated

In Raptor, Repurchase probability is the business-facing name for the model's probability that the customer is still active.

Mathematically:

Repurchase probability = P(customer is active | x, t_x, T, r, α, a, b)

The Modified BG/NBD formula is:

Repurchase probability =
1
─────────────────────────────────────
1 + (a / (b + x)) × ((α + T) / (α + t_x))^(r + x)
Symbol Meaning
x Repeat purchase frequency
tx Time from first order to latest order
T Time from first order to calculation date
r, α, a, b Fitted model parameters

The formula returns a value between 0 and 1. Raptor can display it as a percentage:

Repurchase probability (%) = Repurchase probability × 100

4.1 Intuition behind the formula

The most important part of the formula is:

((α + T) / (α + t_x))^(r + x)

Because Days since last order = Ttx, this term becomes larger when the customer has gone a long time without ordering. When this term becomes larger, the denominator becomes larger, and Repurchase probability becomes lower. This is how the model reacts to inactivity.

However, inactivity is not interpreted as a fixed number of days. It is interpreted in relation to the customer's own purchase pattern and the fitted customer-base behaviour. For example:

  • If a customer normally buys every week but has not bought for two months, the model will usually estimate a lower Repurchase probability.
  • If a customer normally buys every three months and has not bought for two months, the same inactivity period is much less concerning.

This is why Days since last order is interpreted together with purchase frequency, recency, and customer age — not as a standalone rule.

5. How Predicted number of orders next 365 days is calculated

Predicted number of orders next 365 days is the expected number of purchases the customer will place over the next 365 days.

Mathematically:

Predicted number of orders next 365 days = E[Y(365) | x, t_x, T, r, α, a, b]

where Y(365) is the number of future purchases during the next 365 days. This value is an expectation and can therefore be non-integer. For example, a value of 2.4 means that customers with this model state are expected to place 2.4 orders on average over the next 365 days — it does not mean a single customer will literally place 2.4 orders.

5.1 Modified BG/NBD formula

The formula used by ModifiedBetaGeoFitter is:

E[Y(t) | x, t_x, T] =

((a + b + x) / (a − 1)) × [1 − ₂F₁(r + x, b + x + 1; a + b + x; t / (α + T + t)) × ((α + T) / (α + T + t))^(r + x)]
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 + (a / (b + x)) × ((α + T) / (α + t_x))^(r + x)

For Raptor's 365-day prediction, t = 365, so:

Predicted number of orders next 365 days = E[Y(365) | x, t_x, T]

5.2 What is ₂F₁?

₂F₁ is the Gaussian hypergeometric function. It appears because the model does not know each customer's true purchase rate λ or dropout probability p. Instead, the formula integrates over the possible values of λ and p, using the gamma and beta distributions fitted from the customer base.

In simpler terms, the formula does not plug in one fixed purchase rate and one fixed churn probability. It averages over the uncertainty about the customer's true behaviour.

That is why Predicted number of orders next 365 days is more than a simple rule such as:

365 / Average days between orders

or:

Repurchase probability × historical purchase frequency

The model combines the customer's observed repeat purchase frequency, how recently the customer last purchased, how long the customer has been observed, the fitted distribution of purchase rates across customers, and the fitted distribution of dropout probabilities across customers.

6. Why Repurchase probability and predicted orders are related but not the same

Repurchase probability answers: "How likely is the customer to still be active"?

Predicted number of orders next 365 days answers: "How many orders do we expect the customer to place over the next 365 days"?

A customer can have a high Repurchase probability but still have a relatively low predicted number of orders if the customer normally buys infrequently. A customer can also have a lower Repurchase probability but still have meaningful predicted future orders if the customer historically bought very frequently. The two KPIs are therefore related, but they are not the same metric.

7. From predicted orders to future value

Once the model has calculated Predicted number of orders next 365 days, Raptor converts expected orders into expected revenue using Average order value:

Predicted future value next 365 days =
Predicted number of orders next 365 days × Average order value

where:

Average order value = Historical order revenue / Number of orders

Predicted future value next 365 days therefore increases when the customer is expected to place more future orders, or when the customer historically has a higher average order value. The Modified BG/NBD model predicts future order volume; Raptor then converts that order volume into revenue.

8. From future value to Predicted Customer Lifetime Value

Raptor calculates Historic value all time as:

Historic value all time = Sum of all historical order revenue

Then:

Predicted Customer Lifetime Value =
Historic value all time + Predicted future value next 365 days

Expanded:

Predicted Customer Lifetime Value =
Historic value all time
+ Predicted number of orders next 365 days × Average order value

The complete calculation chain is therefore:

Historical orders
→ x, t_x, T, Average order value, Historic value all time
→ fitted Modified BG/NBD parameters: r, α, a, b
→ Repurchase probability
→ Predicted number of orders next 365 days
→ Predicted future value next 365 days
→ Predicted Customer Lifetime Value


9. Practical interpretation

The model is useful because it evaluates inactivity relative to the customer's own historical purchase rhythm. Consider two synthetic customer profiles with the same Historic value all time and the same Average order value.

Customer profile A normally buys every 10 days but has not bought for 90 days. The model sees that Days since last order is high relative to the customer's normal purchase rhythm. Customer profile A will typically receive lower Repurchase probability, lower Predicted number of orders next 365 days, lower Predicted future value next 365 days, and lower Predicted Customer Lifetime Value.

Customer profile B normally buys every 90 days and has not bought for 90 days. The model sees that Days since last order is still consistent with the customer's normal purchase rhythm. Customer profile B may receive higher Repurchase probability, higher Predicted number of orders next 365 days, higher Predicted future value next 365 days, and higher Predicted Customer Lifetime Value.

The same number of inactive days can therefore lead to different predictions for different customers.

10. Worked examples: calculating CLV for two fictional customers

This section shows the full calculation from historical orders to final Predicted Customer Lifetime Value for two fictional customers.

The examples are synthetic and are included only to explain the calculation mechanics. They do not represent real customers, real order histories, production customer data, or customer-specific production parameters.

For this worked example, assume that the Modified BG/NBD model has already been trained and has produced the following fitted parameters: 

r = 0.44
alpha = 6.26
a = 0.12
b = 3.39

The prediction horizon is: 

t = 365 days

The two fictional customers are designed to match a common business interpretation:

Customer profile Description
Customer A Normally buys every week, but has not bought for two months
Customer B Normally buys every three months, and has not bought for two months

To make the examples comparable, both customers have the same: 

Number of orders = 21
Average order value = 100 revenue units
Historic value all time = 21 × 100 = 2,100 revenue units

Since BG/NBD frequency is repeat purchase frequency, both customers have:

x = Number of orders - 1 = 21 - 1 = 20

The difference between the customers is not their historical value. The difference is their purchase rhythm.

Customer A has 20 repeat purchases spread over 140 days, corresponding to approximately one repeat purchase every 7 days.

Customer B has 20 repeat purchases spread over 1,800 days, corresponding to approximately one repeat purchase every 90 days.

Both customers have not purchased for 60 days.

This lets us see how the same inactivity period can be interpreted differently depending on the customer's normal purchase rhythm.

10.1 Shared formulas

The Modified BG/NBD formula for Repurchase probability is:

Repurchase probability =
1 /
[
1
+ a / (b + x)
× ((alpha + T) / (alpha + t_x))^(r + x)
]

The Modified BG/NBD formula for Predicted number of orders next 365 days is:

Predicted number of orders next 365 days = E[Y(365) | x, t_x, T]
E[Y(t) | x, t_x, T]
=
{
(a + b + x) / (a - 1)
×
[
1
- 2F1(r + x, b + x + 1; a + b + x; t / (alpha + T + t))
× ((alpha + T) / (alpha + T + t))^(r + x)
]
}
/
{
1
+ a / (b + x)
× ((alpha + T) / (alpha + t_x))^(r + x)
}

The value formulas are:

Predicted future value next 365 days =
Predicted number of orders next 365 days × Average order value
Predicted Customer Lifetime Value =
Historic value all time + Predicted future value next 365 days

10.2 Customer A: normally buys every week, but has not bought for two months

Customer A normally buys approximately every 7 days, but has not purchased for 60 days.

The customer summary is:

Number of orders = 21
Repeat purchase frequency, x = 20
Average order value = 100
Historic value all time = 2,100
Average days between orders ≈ 7
Days since last order = 60
Time from first order to latest order, t_x = 20 × 7 = 140
Days since first order, T = t_x + Days since last order = 140 + 60 = 200

Step 1: Calculate Repurchase probability

Insert the values into the formula:

Repurchase probability =
1 /
[
1
+ 0.12 / (3.39 + 20)
× ((6.26 + 200) / (6.26 + 140))^(0.44 + 20)
]

First calculate the intermediate terms:

b + x = 3.39 + 20 = 23.39

a / (b + x) = 0.12 / 23.39 = 0.005130

alpha + T = 6.26 + 200 = 206.26

alpha + t_x = 6.26 + 140 = 146.26

(alpha + T) / (alpha + t_x) = 206.26 / 146.26 = 1.410228

r + x = 0.44 + 20 = 20.44

1.410228^20.44 = 1,125.838878

The inactivity odds term is therefore:

0.005130 × 1,125.838878 = 5.776001

The denominator is:

1 + 5.776001 = 6.776001

So:

Repurchase probability = 1 / 6.776001
= 0.147580
= 14.76%

Customer A receives a low Repurchase probability, because 60 days without an order is a long time for a customer who normally buys every week.

Step 2: Calculate Predicted number of orders next 365 days

For Customer A, the denominator in the predicted-orders formula is the same as above:

Denominator = 6.776001

The leading multiplier is:

(a + b + x) / (a - 1)
= (0.12 + 3.39 + 20) / (0.12 - 1)
= 23.51 / -0.88
= -26.715909

The time-horizon input to the hypergeometric function is:

t / (alpha + T + t)
= 365 / (6.26 + 200 + 365)
= 365 / 571.26
= 0.638938

The hypergeometric component is:

2F1(r + x, b + x + 1; a + b + x; t / (alpha + T + t))
=
2F1(20.44, 24.39; 23.51; 0.638938)
≈ 2,506,226,542.227053

The remaining power term is:

((alpha + T) / (alpha + T + t))^(r + x)
=
(206.26 / 571.26)^20.44
≈ 0.000000000906

Multiplying these two terms gives:

2,506,226,542.227053 × 0.000000000906 = 2.269760

The bracketed part of the formula is:

1 - 2.269760 = -1.269760

The numerator is therefore:

-26.715909 × -1.269760 = 33.922803

Finally:

Predicted number of orders next 365 days
= 33.922803 / 6.776001
= 5.006316

So Customer A is expected to place approximately:

5.01 orders over the next 365 days

Step 3: Calculate Predicted future value next 365 days

Predicted future value next 365 days =
Predicted number of orders next 365 days × Average order value

= 5.006316 × 100
= 500.63

Step 4: Calculate Predicted Customer Lifetime Value

Predicted Customer Lifetime Value =
Historic value all time + Predicted future value next 365 days

= 2,100 + 500.63
= 2,600.63

Customer A summary:

Repurchase probability                    = 14.76%
Predicted number of orders next 365 days = 5.01
Predicted future value next 365 days = 500.63
Historic value all time = 2,100.00
Predicted Customer Lifetime Value = 2,600.63


10.3 Customer B: normally buys every three months, and has not bought for two months

Customer B normally buys approximately every 90 days and has not purchased for 60 days.

The customer summary is:

Number of orders = 21
Repeat purchase frequency, x = 20
Average order value = 100
Historic value all time = 2,100
Average days between orders ≈ 90
Days since last order = 60
Time from first order to latest order, t_x = 20 × 90 = 1,800
Days since first order, T = t_x + Days since last order = 1,800 + 60 = 1,860

Step 1: Calculate Repurchase probability

Insert the values into the formula:

Repurchase probability =
1 /
[
1
+ 0.12 / (3.39 + 20)
× ((6.26 + 1,860) / (6.26 + 1,800))^(0.44 + 20)
]

First calculate the intermediate terms:

b + x = 3.39 + 20 = 23.39

a / (b + x) = 0.12 / 23.39 = 0.005130

alpha + T = 6.26 + 1,860 = 1,866.26

alpha + t_x = 6.26 + 1,800 = 1,806.26

(alpha + T) / (alpha + t_x) = 1,866.26 / 1,806.26 = 1.033218

r + x = 0.44 + 20 = 20.44

1.033218^20.44 = 1.950213

The inactivity odds term is therefore:

0.005130 × 1.950213 = 0.010005

The denominator is:

1 + 0.010005 = 1.010005

So:

Repurchase probability = 1 / 1.010005
= 0.990094
= 99.01%

Customer B receives a high Repurchase probability, because 60 days without an order is still consistent with a customer who normally buys every three months.

Step 2: Calculate Predicted number of orders next 365 days

For Customer B, the denominator in the predicted-orders formula is:

Denominator = 1.010005

The leading multiplier is the same as for Customer A, because x, a, and b are the same:

(a + b + x) / (a - 1)
= (0.12 + 3.39 + 20) / (0.12 - 1)
= -26.715909

The time-horizon input to the hypergeometric function is:

t / (alpha + T + t)
= 365 / (6.26 + 1,860 + 365)
= 365 / 2,231.26
= 0.163585

The hypergeometric component is:

2F1(r + x, b + x + 1; a + b + x; t / (alpha + T + t))
=
2F1(20.44, 24.39; 23.51; 0.163585)
≈ 44.229125

The remaining power term is:

((alpha + T) / (alpha + T + t))^(r + x)
=
(1,866.26 / 2,231.26)^20.44
≈ 0.025960

Multiplying these two terms gives:

44.229125 × 0.025960 = 1.148189

The bracketed part of the formula is:

1 - 1.148189 = -0.148189

The numerator is therefore:

-26.715909 × -0.148189 = 3.959003

Finally:

Predicted number of orders next 365 days
= 3.959003 / 1.010005
= 3.919784

So Customer B is expected to place approximately:

3.92 orders over the next 365 days

Step 3: Calculate Predicted future value next 365 days

Predicted future value next 365 days =
Predicted number of orders next 365 days × Average order value

= 3.919784 × 100
= 391.98

Step 4: Calculate Predicted Customer Lifetime Value

Predicted Customer Lifetime Value =
Historic value all time + Predicted future value next 365 days

= 2,100 + 391.98
= 2,491.98

Customer B summary:

Repurchase probability                    = 99.01%
Predicted number of orders next 365 days = 3.92
Predicted future value next 365 days = 391.98
Historic value all time = 2,100.00
Predicted Customer Lifetime Value = 2,491.98


10.4 Comparison of the two customers

Metric Customer A: weekly buyer, inactive 60 days Customer B: 90-day buyer, inactive 60 days
Number of orders 21 21
Repeat purchase frequency x 20 20
Average days between orders 7 90
Days since last order 60 60
Time from first order to latest order t_x 140 1,800
Days since first order T 200 1,860
Average order value 100.00 100.00
Historic value all time 2,100.00 2,100.00
Repurchase probability 14.76% 99.01%
Predicted number of orders next 365 days 5.01 3.92
Predicted future value next 365 days 500.63 391.98
Predicted Customer Lifetime Value 2,600.63 2,491.98

The important point is that both customers have the same historical revenue and the same Days since last order, but the model interprets the 60 days of inactivity very differently.

For Customer A, 60 days without an order is unusual because the customer normally buys every week. This results in a low Repurchase probability.

For Customer B, 60 days without an order is not unusual because the customer normally buys every three months. This results in a high Repurchase probability.

At the same time, Customer A still has a slightly higher Predicted number of orders next 365 days. This is because Customer A's underlying purchase rhythm is much more frequent. If Customer A is still active, the expected order rate is high. This illustrates why Repurchase probability and Predicted number of orders next 365 days are related, but not the same metric.

11. Model validation concept

The model can be validated by fitting it on an earlier calibration period and comparing predicted future orders with actual future orders in a later holdout period: 

1. Fit model on historical calibration period
2. Predict future order volume
3. Compare predicted orders with actual observed orders in the holdout period

This checks whether the fitted model can predict future purchase activity for an existing customer base. For CLV purposes, the main goal is not to predict the exact number of orders in each individual week — it is to estimate expected future order volume over the 365-day horizon.


12. Summary

Raptor's customer value calculation can be summarised as follows:

1. Historical orders are aggregated per customer.

2. Each customer is represented by:
- x: repeat purchase frequency
- t_x: time from first order to latest order
- T: time from first order to calculation date
- Average order value
- Historic value all time

3. A Modified BG/NBD model is fitted across the customer base.

4. The model estimates the parameters:
- r and α: variation in purchase rates
- a and b: variation in dropout probabilities

5. Repurchase probability is calculated as:
P(customer is active | x, t_x, T, r, α, a, b)

6. Predicted number of orders next 365 days is calculated as:
E[Y(365) | x, t_x, T, r, α, a, b]

7. Predicted future value next 365 days is calculated as:
Predicted number of orders next 365 days × Average order value

8. Predicted Customer Lifetime Value is calculated as:
Historic value all time + Predicted future value next 365 days

The Modified BG/NBD model is the statistical engine that estimates future purchase activity. Raptor then translates predicted activity into revenue and combines it with historical revenue to produce Predicted Customer Lifetime Value.

 

Formula appendix

Repurchase probability

Repurchase probability =
1
─────────────────────────────────────────────────
1 + (a / (b + x)) × ((α + T) / (α + t_x))^(r + x)

Predicted number of orders next 365 days

E[Y(t) | x, t_x, T] =

((a + b + x) / (a − 1)) × [1 − ₂F₁(r + x, b + x + 1; a + b + x; t / (α + T + t)) × ((α + T) / (α + T + t))^(r + x)]
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 + (a / (b + x)) × ((α + T) / (α + t_x))^(r + x)

For Raptor: t = 365

Predicted future value next 365 days

Predicted future value next 365 days =
Predicted number of orders next 365 days × Average order value

Predicted Customer Lifetime Value

Predicted Customer Lifetime Value =
Historic value all time + Predicted future value next 365 days


References

  • Batislam, E. P., Denizel, M., and Filiztekin, A. (2007). Empirical validation and comparison of models for customer base analysis. International Journal of Research in Marketing, 24(3), 201–209.
  • Wagner, U. and Hoppe, D. (2008). Erratum on the MBG/NBD Model. International Journal of Research in Marketing, 25(3), 225–226.
  • Lifetimes Python package: ModifiedBetaGeoFitter.
  • Lifetimes documentation.