-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Improvements for quadrature routines #35
Comments
Not sure I understand when you would use a column of zeros in a covariance matrix, doesn't that mean that the variance of that random variable would be zero? I think everything else (especially the names) is a good idea for discussion. |
Imagine you have a model that depends on two i.i.d. gaussian shocks. You sigma = array([[sigma1, 0],[0, sigma2]]) Assume that you have written a routine to solve your model involving a On Wed, Jul 30, 2014 at 10:21 PM, cc7768 notifications@github.com wrote:
|
The current If we do move away from In the end I would love to have tests that were checking for the "correct answer" rather than simply verifying that we match some other code. Does anyone have any references we can turn to for computing the correct answers for any of these routines? If we can separate our tests from the Matlab versions, then I would love to move on and make this feel more pythonic. |
I will look into the dimensionality issues and probably write some tests for them. I haven't checked simple (yet important) things like that yet, so this is great feedback. |
I'm in favor of changing the names to something more informative. Let's not tie ourselves down to exactly replicating CompEcon. As long as we implement broadly similar functionality and have good documentation I think it's fine to deviate when the deviation involves an obvious improvement. Regarding the suggestion to "rename quad.py into ce_quad.py so that the latter can be left untouched and remain as close as possible from the original version (including Fortran order). A quadrature.py could then contain Python compliant versions, possibly with more explicit names." My preference would be to avoid duplication, just have one version of these routines and go for Python compliance and more explicit names. Let's break compatibility if it leads to improvement. As long as we have good documentation I think that's fine. |
About the reordering and subsequent testing issues. It's clear that current tests for multidimensional integration will break and will need to be rewritten. There are two simple ways to get around that:
|
I've been looking at this issue again since the |
Since the quad branch is closed, I'm opening a new issue with the comments I made about it, so that we can start a fresh discussion.
There are currently a few issues with the quadrature routines. The two items can have side-effects on future code and should be fixed quickly.
gridmake
function does not enumerate points in a way that is consistent with default Python conventions. If you computegridmake(array([0,1]), ([-1,2]))
it produces:meaning that the first order varies faster. Now, if you want to represent values on this grid by a 2d array
vals
such thatvals[i,j]
contains values, then when you do vals.ravel(), you don't enumerate points in the same order because last index is supposed to vary faster. This one is quite annoying.quad.qnwnorm([2,2])
I get 2-dimensional arrays and with qnwnorm([2]) I get 1-dimensional vectors. This is problematic, since in generic code, it will force one to always distinguish dimension 1 from higher dimensions. My opinion here is that multidimensional routines, should always return multidimensional objects in a predictible fashion. (maybe the 1-d routines could be exported too)qnwnorm
and co, don't we ?A possible way to deal with these issues would be to rename quad.py into ce_quad.py so that the latter can be left untouched and remain as close as possible from the original version (including Fortran order). A
quadrature.py
could then contain Python compliant versions, possibly with more explicit names.As for the
gridmake
replacement, the functioncartesian
does the required thing. It is also faster. (cf http://stackoverflow.com/questions/1208118/using-numpy-to-build-an-array-of-all-combinations-of-two-arrays)Actually all these issues concern only the multidimensional functions.
The text was updated successfully, but these errors were encountered: