-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend exact posteriors to condition on multiple observations #125
Comments
Does the following illustrate the problem you're talking about—or part of it? import aemcmc
import aesara
import aesara.tensor as at
srng = at.random.RandomStream(0)
lam_rv = srng.gamma(1., 1., name="lam")
Y1_rv = srng.poisson(lam=lam_rv, name="Y1")
Y2_rv = srng.poisson(lam=lam_rv, name="Y2")
y1_vv = Y1_rv.clone()
y1_vv.name = "y1"
y2_vv = Y2_rv.clone()
y2_vv.name = "y2"
sampler, initial_values = aemcmc.construct_sampler({Y1_rv: y1_vv, Y2_rv: y2_vv}, srng)
p_posterior_step = sampler.sample_steps[lam_rv]
# Only one posterior sampling step for `lam_rv`
sampler.sample_steps.keys()
# dict_keys([lam])
# and it only uses the value of `Y2_rv` (i.e. `y2`)
aesara.dprint(p_posterior_step)
# gamma_rv{0, (0, 0), floatX, False}.1 [id A]
# |RandomGeneratorSharedVariable(<Generator(PCG64) at 0x7FDEAC9F9660>) [id B]
# |TensorConstant{[]} [id C]
# |TensorConstant{11} [id D]
# |Elemwise{add,no_inplace} [id E]
# | |TensorConstant{1.0} [id F]
# | |y2 [id G]
# |Elemwise{true_divide,no_inplace} [id H]
# |TensorConstant{1.0} [id I]
# |Elemwise{add,no_inplace} [id J]
# |TensorConstant{1.0} [id F]
# |TensorConstant{1} [id K] This example seems like it might require a new relation (e.g. the sum of independent Poissons being a Poisson) in order to give the expected result. At the very least, it should be aware of the other observed Poisson. |
Yes, definitely part of it. I was wondering if AeMCMC has the structure to emulate/automate common conjugate distributions as in this Wiki table. These likelihoods assume some I imagine that, eventually, instead of having |
Why would we need to recognize that a sum of independent Poissons is a Poisson? The likelihood portion of the posterior kernel is the same as a sum of Poissons, but maybe that's just a coincidence here? Here are some math scribbles: where the kernel of |
Absolutely; that's a big part of this work (e.g. #48, #46). The current conjugation implementations are mostly framed as |
That's just one fairly straightforward approach to handling this exact situation, but there are likely many others. The reason that approach is nice: we need only add one simple additional rewrite and it should immediately work with the current rewrites to produce the desired result. In other words, we wouldn't need to change how things work.
Yeah, it looks like you're deriving the rewrite I proposed adding, but in "log-density space". Our rewrite process operates primarily in a "measurable function/random variable space": i.e. on random variables like Using this approach, we avoid all the extra machinery needed to perform the log-density derivation/proof of |
Thanks for the clarifications above
I think that I'm missing something here. I was referring to |
You're right, that one identity won't work in general. What I'm talking about is the general approach of operating in a non-(log-)density space, for which that convolution identity is just a single example (Sorry, been on the last part of a big project for a little while now; will provide a real response as soon as I can!) |
Description of your problem or feature request
It is my understanding that current exact posteriors, e.g.$Y \sim \text{Poisson}$ rather than a set of i.i.d. observations $Y_1, \dots, Y_n$ . How can current conjugate relations be extended for multiple observations?
gamma_poisson_conjugateo
, can only condition on a single observationCan we allow arguments such as
realized
(akin tojoint_logprob
in AePPL) orrealized_rvs_to_values
in the AeMCMC's nuts'construct_sampler
in AeMCMC's generalconstruct_sampler
?Currently,
sample_fn(np.array([2, 3, 4])
yields a 3-dimensional array.cc @brandonwillard @rlouf
The text was updated successfully, but these errors were encountered: