# [Numpy-discussion] inversion of large matrices

Melissa Mendonça melissawm@gmail....
Mon Aug 30 16:42:52 CDT 2010

```Hi,

I've been lurking for a while here but never really introduced myself.
I'm a mathematician in Brazil working with optimization and numerical
analysis and I'm looking into scipy/numpy basically because I want to
ditch matlab.

I'm just curious as to why you say "scipy.linalg.solve(), NOT
numpy.linalg.solve()". Can you explain the reason for this? I find
myself looking for information such as this on the internet but I
rarely find real documentation for these things, and I seem to have so
many performance issues with python... I'm curious to see what I'm
missing here.

Thanks, and sorry if I hijacked the thread,

- Melissa

On Mon, Aug 30, 2010 at 3:59 PM, David Warde-Farley <dwf@cs.toronto.edu> wrote:
>
> On 2010-08-30, at 11:28 AM, Daniel Elliott wrote:
>
>> Hello,
>>
>> I am new to Python (coming from R and Matlab/Octave).  I was preparing
>> to write my usual compute pdf of a really high dimensional (e.g. 10000
>> dimensions) Gaussian code in Python but I noticed that numpy had a
>> function for computing the log determinant in these situations.
>
> Yep. Keep in mind this is a fairly recent addition, in 1.5 I think, so if you ship code make sure to list this dependency.
>
>> Is there a function for performing the inverse or even the pdf of a
>> multinomial normal in these situations as well?
>
>
> There's a function for the inverse, but you almost never want to use it, especially if your goal is the multivariate normal density. A basic explanation of why is available here: http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/
>
> In the case of the multivariate normal density the covariance is assumed to be positive definite, and thus a Cholesky decomposition is appropriate. scipy.linalg.solve() (NOT numpy.linalg.solve()) with the sym_pos=True argument will do this for you.
>
> What do you mean by a "multinomial normal"? Do you mean multivariate normal? Offhand I can't remember if it exists in scipy.stats, but I know there's code for it in PyMC.
>
> David
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>

--
Melissa Weber Mendonça
--
"Knowledge is knowing a tomato is a fruit; wisdom is knowing you don't