Skip to content

Commit

Permalink
Optimisation in customer_lifetime_value when discount_rate == 0
Browse files Browse the repository at this point in the history
cf #467
  • Loading branch information
vincent-grosbois committed Dec 27, 2023
1 parent 6ecdb08 commit 8666530
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pymc_marketing/clv/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ def _squeeze_dims(x: xarray.DataArray):
x = x.squeeze(dims_to_squeeze)
return x

steps = np.arange(1, time + 1)
if discount_rate == 0.0:
# no discount rate: just compute a single time step from 0 to `time`
steps = np.arange(time, time + 1)
else:
steps = np.arange(1, time + 1)

factor = {"W": 4.345, "M": 1.0, "D": 30, "H": 30 * 24}[freq]

# Monetary value can be passed as a DataArray, with entries per chain and draw or as a simple vector
Expand Down

0 comments on commit 8666530

Please sign in to comment.