[SciPy-user] Structured matrices

Fernando Perez fperez.net@gmail....
Fri Mar 16 13:02:28 CDT 2007


On 3/16/07, Barry Drake <bldrake@adaptcs.com> wrote:
> Anand,
> Since the matrix is not symmetric, how can it be a covariance matrix?

Why do you say it's not symmetric?  Using Anne's beautiful one-liner:

In [223]: ss = lambda s: minimum.outer(r_[s:-1:-2],r_[s:-1:-2])

Checking for s=9:

In [224]: ss(9)
Out[224]:
array([[9, 7, 5, 3, 1],
       [7, 7, 5, 3, 1],
       [5, 5, 5, 3, 1],
       [3, 3, 3, 3, 1],
       [1, 1, 1, 1, 1]])


Structurally it seems pretty obvious they must be symmetric always,
and it's also straightforward to do an explicit check over a number of
sizes:

In [225]: sszero = lambda s: abs(ss(s)-ss(s).T).max()

In [226]: [sszero(n) for n in range(3,45,2)]
Out[226]: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]


Am I missing something?

Cheers,

f


More information about the SciPy-user mailing list