INNER CODE UNIT · Python

next_purchase_in

CamDavidsonPilon/lifetimes · lifetimes/generate_data.py:54

        next_purchase_in = random.exponential(scale=1.0 / l)
        alive = True
        while (np.sum(times) + next_purchase_in < T[i]) and alive:
            times.append(next_purchase_in)
            next_purchase_in = random.exponential(scale=1.0 / l)
            alive = random.random() > p

        times = np.array(times).cumsum()
        df.iloc[i] = (
            np.unique(np.array(times).astype(int)).shape[0],
            np.max(times if times.shape[0] > 0 else 0),
            T[i],
            l,
            p,
            alive,
            i,
        )

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…