import matplotlib.pyplot as plt
import numpy as np
import pytensor.tensor as pt
import pytensor.xtensor as ptx
from pymc_marketing.mmm.transformers import binomial_adstock
l_max = 12
params = [ 0.1, 0.3, 0.5, 0.7, 0.9]
spend_np = np.zeros(15); spend_np[0] = 1
spend = ptx.as_xtensor(pt.as_tensor_variable(spend_np), dims=('time',))
ax = plt.subplot(111)
x = np.arange(len(spend_np))
for a in params:
    y = binomial_adstock(spend, alpha=a, l_max=l_max, dim='time').eval()
    plt.plot(x, y, label=f'alpha = {a}')
plt.xlabel('time since spend', fontsize=12)
plt.title(f'Binomial Adstock with l_max = {l_max}', fontsize=14)
plt.ylabel('f(time since spend)', fontsize=12)
box = ax.get_position()
ax.set_position([box.x0, box.y0, box.width * 0.65, box.height])
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
plt.show()