I would like to do MAP estimation where likelihood and prior are both Rician distributions. Since Rician distribution is not implemented, I am not sure how to efficiently do it. I want to estimate x from y such that
y|x = sqrt(z1^2 + z2^2)
x = sqrt(z3^2 + z4^2)
where zi are all independent Gaussian s.t. z1 ~ N(xcos(t), r1), z2 ~ N(xsin(t), r1), z3 ~ (vcos(t), r2), z4 ~ (vsin(t), r2).
Hi @keseiya, I think the easiest solution would be to implement a custom distribution that defines .log_prob() but not .sample(). Looking a the wikipedia page something like this should work:
To validate you could either check against another distribution implementation (e.g. scipy) or implement a .sample() method (by sampling a 2D random variable and computing its norm) and test via pyro.distributions.testing.gof() as in this test code.
If you use this in variational inference with AutoGuides, Iād recommend initializing with init_to_feasible, which avoids the need to draw samples.
For future readers of this thread, try this for log_prob method. The difference here is that we use torch.special.i0e instead of torch.special.i0. torch.special.i0 can return infinity easily if the input value is not very small and therefore, mess up your gradient calculation.