Skip to content

Spate of (largely cosmetic) changes to distributions.py, alternate inverse_wishart implementation, etc. #3

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
11 commits merged into from
Nov 22, 2010

Conversation

wesm
Copy link
Contributor

@wesm wesm commented Oct 23, 2010

Sorry about all the spam today guys. I'm a 1st-year PhD student at Duke and I decided it'd be time well-invested to help develop PyMC rather than cooking up my own bayesian stats library in Python.

The only significant things here are:

  • inverse wishart distribution parameterized with the precision matrix Sigma^-1
  • changed rwishart_cov to use rwishart because they were coming up with different results for the same random seed (I wrote a unit test to compare them).
  • updated docs to reflect new distribution, unit tests
  • added a couple directories to .gitignore

I apologize in advance that you may find me compulsively reformatting code to be more in line with PEP 8. The main thing that bothers me is lines of code being too wide for my emacs buffers-- I hope I'm not the only one. I'd like to think this will make the code easier for others to read.

Cheers,

wesm added 7 commits October 22, 2010 11:50
rwishart and rwishart_cov were producing different results for the same
random seed (the random variables inside are generated in the same order)
   clarify use of covariance (scale) instead of precision

 * Implemented inverse wishart distribution parameterized using
   precision matrix

 * More unit tests to check consistency of cov / precision based
   wishart / inverse wishart-based samples / likelihoods

 * A little bit of code reformatting and fixed earlier M-q reformats
@apatil
Copy link
Contributor

apatil commented Oct 23, 2010

Thanks very much, Wes, I'll have a look at this Monday.

Anand

@apatil
Copy link
Contributor

apatil commented Oct 25, 2010

Very nice. One thing is that I don't think you'd expect rwishart and rwishart_cov to give the same result for the same random seed. The same random seed means that the same random variates will be produced, but one is using an LL^T factorization whereas the other is effectively using a UU^T factorization, meaning they can both be correct yet give different answers.

I think the RV's generated by the two are identically distributed, see http://gist.github.com/644869 . Do you agree? If so, the existing implementation is preferable because it saves a matrix inversion and so should be a bit faster.

Anand

@wesm
Copy link
Contributor Author

wesm commented Oct 25, 2010

You're right about rwishart_cov, looking more carefully at the linear algebra and it makes sense now.

Also I changed a parameter name in the inverse_wishart functions from Tau to Sigma since it's expecting a covariance matrix and not a precision matrix-- but I see this is breaking a unit test. I don't want to break anyone's code so I can change this back-- let me know what I should do.

I can make these two changes and let you pull if everything else looks good.

Thanks,
Wes

@wesm
Copy link
Contributor Author

wesm commented Oct 25, 2010

BTW I'll try to be cleaner about proposing changes to the codebase next time. I assume the correct git workflow is:

make a branch wesm/set-of-changes-or-new-feature
make changes, merge into master when done
send pull request for wesm/set-of-changes-or-new-feature

@apatil
Copy link
Contributor

apatil commented Oct 25, 2010

Cool. As far as the name change, we want to keep the parameterizations consistent with Wikipedia unless there's a good reason not to, and I think your change does that. However, I'd prefer C to Sigma in order to keep consistency with the mv normal distribution.

As far as breaking peoples' code, it's definitely a concern but I don't know who is using the Wishart distribution right now. I'll post to the ML and ask.

Thanks for sticking with this!

Anand
Anand

@apatil
Copy link
Contributor

apatil commented Oct 25, 2010

Regarding cleanliness, you're doing fine!

@apatil
Copy link
Contributor

apatil commented Nov 1, 2010

People have had a while to speak up now if the name change causes them problems... I think we're good to go ahead.

@wesm
Copy link
Contributor Author

wesm commented Nov 1, 2010

OK I will make the name change a bit later and let you know when it's safe to merge. Thanks!

@wesm
Copy link
Contributor Author

wesm commented Nov 4, 2010

Merge away-- let me know if you have any trouble.

Cheers,
Wes

jsalvatier added a commit that referenced this pull request Aug 6, 2012
Fixed ImportError for submodules
This pull request was closed.
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.

2 participants