[Numpy-discussion] determinant of a scalar not handled

Skipper Seabold jsseabold@gmail....
Tue Jul 27 11:17:32 CDT 2010


On Tue, Jul 27, 2010 at 10:01 AM, Alan G Isaac <aisaac@american.edu> wrote:
>> On Mon, Jul 26, 2010 at 10:05 PM, Alan G Isaac<aisaac@american.edu>  wrote:
>>> But I am still confused about the use case.
>>> What is the scalar- (or 1d-array-) returning procedure
>>> invoked before taking the determinant?
>
>
> On 7/27/2010 8:51 AM, Skipper Seabold wrote:
>> Recently I ran into this trying to make the log-likelihood of a
>> multivariate and univariate autoregressive process use the same
>> function.  One has log(sigma_scalar) and one calls for
>> logdet(Sigma_matrix).  I also ran in to again yesterday working on the
>> Kalman filter, depending on the process being modeled and how the user
>> writes a function if the needed coefficient arrays depend on
>> parameters.  To be more general, I have to put in atleast_2d, even
>> though these checks are really in slogdet.
>
>
> OK, I see.  Two comments, without going over the code.
>
> 1. It seems the problem really arises earlier, when
> computing the residuals.  I suppose the single equation code
> produces a 1d array, while the multi-equation code must
> produce a 2d array of residuals.  This seems
> like the better place to fix things if you want
> general handling: make sure the residuals are always 2d.
>

This is usually where it shows up.

a = np.ones(10)
np.dot(a,a)/1.
#10.0

Changing to all 2d arrays is probably the sensible thing to do, though
we would have to change some (many?) results held as floats to 1x1
arrays.  Trying to use all 1d vectors as 2d arrays I recall having to
insert both atleast_2d and squeezes all over the place.  Maybe I will
have another look.

Skipper


More information about the NumPy-Discussion mailing list