If you have a matrix a of standard normal deviates, you can make it symmetric with

asymm =: (+ |:) a

but what is the variance of the items of a?

The variance of values off the principal diagonal will be the sum of the variance of two independent standard normal deviates. i.e. 2.

To return these values to variance 1 you need to divide by sqrt(2).

But the variance of values ON the principal diagonal will be the sum of two perfectly correlated random variables, i. e. 4.

So you need to treat the principal diagonal differently. You can reduce its variance by scaling it differently after the conversion to symmetric, dividing the diagonal by sqrt(4) and the rest by sqrt(2):

asymmgood =: asymm % %: +: >: e. i. # asymm

(The e. i. bit is a standard idiom for making an identity matrix. Another one you see around is = i. but I avoid that because I think monad = was wrongly defined and should be assigned for other purposes)

If I've made a statistical blunder I'm sure someone will tell me.

Henry Rich

On 8/21/2012 3:10 PM, Owen Marschall wrote:
Ah, just what I needed. Thanks!

On Aug 21, 2012, at 1:06 PM, Ric Sherlock wrote:

The primitive ( |: ) is transpose. E.g. :

   |: i. 3 4
0 4  8
1 5  9
2 6 10
3 7 11
On Aug 22, 2012 6:55 AM, "Owen Marschall" <[email protected]> wrote:

Anyone know of an easy way to create a random symmetric matrix (more
specifically, a matrix whose entires are each picked from a standard
Gaussian distribution)? I can start by doing

load 'stats'
R=:normalrand N N

but this is not symmetric, and I don't know of any way to symmetrize it
without thinking in loops, which I'm training myself not to. If I could
somehow take a transpose, that would solve the problem, but I don't know
how to do that either.

Thanks,
Owen
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to