stripe / rainier

Bayesian inference in Scala.
https://rainier.fit
Apache License 2.0
433 stars 51 forks source link

Can't Retrieve Information on Distribution after Inference #505

Closed saucetray closed 2 years ago

saucetray commented 2 years ago

I am trying to use this library to do AB testing... I need to fit a prior before and I think using inference is fine. However, I can't retrieve the value for the scale of Gamma in location or scale. I can optimize to find the location using historical.optimize(location) but that's it.

val location = Gamma(0.5, 100).latent
val scale = Gamma(0.5, 100).latent

val historical = Model.observe(someList, LogNormal(location, scale))

I need to be able to do that and then use the values to run inference like this

optimizedLocation = historical.optimize(location)
optimizedScale = historical.optimize(scale)

val control = Model.observe(someOtherList, LogNormal(optimizedLocation, optimizedScale))
val treatment = Model.observe(someOtherOtherList, LogNormal(optimizedLocation, optimizedScale))

However, this doesn't work because the sampler breaks since I am using scalars... So I thought the solution would be to then create more latent variables using the learned location and scale but I can only obtain their means for gamma and not their scales. How can I solve this?

avibryant commented 2 years ago

I think it would help if you took a step back and wrote down your model, because it's not clear from this what your priors are and what you are trying to infer.

If you're unfamiliar with setting up bayesian models, which I suspect you might be, I would suggest working through Statistical Rethinking which is an excellent text book and also has free online lectures.