On Tue, 15 Sep 2009 13:31:21 -0600, Charles R Harris wrote: > On Tue, Sep 15, 2009 at 1:28 PM, Michael Gilbert < > michael.s.gilb...@gmail.com> wrote: > > > On Tue, 15 Sep 2009 13:17:43 -0600, Charles R Harris wrote: > > > On Tue, Sep 15, 2009 at 12:57 PM, Michael Gilbert < > > > michael.s.gilb...@gmail.com> wrote: > > > > > > > On Tue, 15 Sep 2009 13:26:23 -0500, Robert Kern wrote: > > > > > On Tue, Sep 15, 2009 at 12:50, Charles R > > > > > Harris<charlesr.har...@gmail.com> wrote: > > > > > > > > > > > > > > > > > > On Tue, Sep 15, 2009 at 11:38 AM, Michael Gilbert > > > > > > <michael.s.gilb...@gmail.com> wrote: > > > > > >> > > > > > >> hi, > > > > > >> > > > > > >> when using numpy.random.multivariate_normal, would it make sense > > to > > > > warn > > > > > >> the user that they have entered a non-physical covariance matrix? > > i > > > > was > > > > > >> recently working on a problem and getting very strange results > > until i > > > > > >> finally realized that i had actually entered a bogus covariance > > > > matrix. > > > > > >> > > > > > >> its easy to determine when this is the case -- its when the > > > > > >> determinant of the covariance matrix is negative. i.e. the > > > > > >> multivariate normal distribution has det(C)^1/2 as part of the > > > > > >> normalization factor, so when det(C)<0, you end up with an > > imaginary > > > > > >> probability distribution. > > > > > >> > > > > > > > > > > > > Hmm, you mean it isn't implemented using a cholesky decomposition? > > That > > > > > > would (should) throw an error if the covariance isn't symmetric > > > > positive > > > > > > definite. > > > > > > > > > > We use the SVD to do the matrix square root. I believe I was just > > > > > following the older code that I was replacing. I have run into nearly > > > > > degenerate cases where det(C) ~ 0 such that the SVD method gave not > > > > > unreasonable answers, given the circumstances, while the Cholesky > > > > > decomposition gave an error "too soon" in my estimation. > > > > > > > > i just tried a non-symmetric covariance matrix, which, like you > > > > mention is also non-physical. there were also no errors for this > > > > situation, and the results will obviously be incorrect. > > > > > > > > regardless of the method for determining the matrix square root, it > > > > should be possible to determine whether an error needs to be thrown > > > > based on whether or not the result is imaginary, right? > > > > > > > > > > > The singular values should all be non-negative, if not there is a bug > > > somewhere. Can you post the matrix that has the negative singular values? > > > The symmetry can be checked in various ways. I think some sort of check > > > would be appropriate. Open a ticket. > > > > will do. where is your tracker at? > > > > Go to www.scipy.org, click on the bug icon, and follow directions.
ok. i didn't realize numpy bugs were tracked along with scipy bugs. there is no mention of that on the numpy.scipy.org page. mike _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion