Time Varying Overdispersed Poisson Process

My eventual goal is to build a threshold based anomaly detection model for count data with a time varying poisson process, but since it’s overdispersed I made it a negative binomial distribution with the gamma distribution, so I don’t want to drop this part without knowing its not necessary since I know its overdispersed. Right now I’m trying to simulate fake data to make sure I return the right parameter values, and then I’ll add in fake anomalies, and then I’ll try and apply this to a few real datasets.

It turns out the shape=len(df1) argument is contributing quite a bit to the time, as its fitting a parameter for every single observation - trying to find another way around it but I have a feeling figuring out an alternative will speed things back up

Also great points with all priors I appreciate all the feedback on that