numpy (matrix solver) - python vs. matlab

Russ P. russ.paielli at gmail.com
Tue May 1 02:56:48 EDT 2012


On Apr 29, 5:17 pm, someone <newsbo... at gmail.com> wrote:
> On 04/30/2012 12:39 AM, Kiuhnm wrote:
>> >> So Matlab at least warns about "Matrix is close to singular or badly
> >> scaled", which python (and I guess most other languages) does not...
>> > A is not just close to singular: it's singular!
>> Ok. When do you define it to be singular, btw?
>> >> Which is the most accurate/best, even for such a bad matrix? Is it
> >> possible to say something about that? Looks like python has a lot more
> >> digits but maybe that's just a random result... I mean.... Element 1,1 =
> >> 2.81e14 in Python, but something like 3e14 in Matlab and so forth -
> >> there's a small difference in the results...
>> > Both results are *wrong*: no inverse exists.
>> What's the best solution of the two wrong ones? Best least-squares
> solution or whatever?
>> >> With python, I would also kindly ask about how to avoid this problem in
> >> the future, I mean, this maybe means that I have to check the condition
> >> number at all times before doing anything at all ? How to do that?
>> > If cond(A) is high, you're trying to solve your problem the wrong way.
>> So you're saying that in another language (python) I should check the
> condition number, before solving anything?
>> > You should try to avoid matrix inversion altogether if that's the case.
> > For instance you shouldn't invert a matrix just to solve a linear system.
>> What then?
>> Cramer's rule?

If you really want to know just about everything there is to know
about a matrix, take a look at its Singular Value Decomposition (SVD).
I've never used numpy, but I assume it can compute an SVD.


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /