Skip to content

Instantly share code, notes, and snippets.

View AlejandroRamirezLopez's full-sized avatar

AlejandroRamirezLopez

View GitHub Profile
@honake
honake / adstock.py
Last active November 17, 2022 06:54
Calculate the optimal Ad Stock
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
def broadbent_adstock(grp, r):
adstock = np.zeros(len(grp))
adstock[0] = grp[0]
for i in range(1,len(grp)):
adstock[i] = grp[i] + r*adstock[i-1]
return adstock