Skip to content

Fix for #3270 #3293

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

Merged
merged 8 commits into from
Jan 3, 2019
Merged

Fix for #3270 #3293

merged 8 commits into from
Jan 3, 2019

Conversation

lucianopaz
Copy link
Member

@lucianopaz lucianopaz commented Dec 7, 2018

close #3246 and close #3270
It was quite hard to get the mixture class random method to work. To finish the fix for #3270 I also had to write a random method for the LKJCholeskyCov class. It was quite a cumbersome fix and I still need to add new tests to the testsuite.

@@ -998,6 +1013,90 @@ def logp(self, x):

return norm + logp_lkj + logp_sd + det_invjac

def _random(self, n, eta, size=1):
eta_sample_shape = (size,) + eta.shape
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there are large overlap with the LKJCorr random implementation, we should isolate the function outside of the class so both LKJCorr and LKJCorrCholesky can call it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I honestly just copied LKJCorr.random and took the cholesky decomposition at the end because I don't know if there is an algorithm that efficiently samples the cholesky decomposition straight away.
One other thing that I wanted to ask some help with was writing a test like lkj's distribution random, but for the cholesky decomposition with the sd_dist.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I need to double check the paper but if I remember correctly, LKJCorr random generate a cholesky factor for the correlation matrix, so you just need to add the diagonal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@junpenglao any update?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lucianopaz @twiecki Yes the current implementation generate a Cholesky factor (P in the random generation code), we can then use the LDL decomposition https://en.wikipedia.org/wiki/Cholesky_decomposition#LDL_decomposition to generate the LKJCorrCholesky.

@twiecki
Copy link
Member

twiecki commented Dec 29, 2018

Needs a rebase.

@@ -245,6 +246,23 @@ def parent(self):
return self._parent


class _DrawValuesContextBlocker(six.with_metaclass(InitContextMeta,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python 2 is deprecated.

@twiecki twiecki merged commit c73f97d into pymc-devs:master Jan 3, 2019
@twiecki
Copy link
Member

twiecki commented Jan 3, 2019

Thanks @lucianopaz !

@lucianopaz
Copy link
Member Author

Thanks @lucianopaz !

Thanks! However, this PR still had some rough edges. In particular, I still had not implemented tests for LKJCholeskyCov.random. Another thing is that I had not merged the LKJCholeskyCov and LKJCorr's random methods. I can try to do this some time next week, and maybe open a new issue to reference this.

@twiecki
Copy link
Member

twiecki commented Jan 4, 2019

@lucianopaz OK, sounds good. Let's apply the WIP label in the future.

@lucianopaz lucianopaz deleted the iss3270 branch February 24, 2019 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

multivariate mixture random method is broken sample_prior_predictive does not work for simple model with LKJ distribution
3 participants