From: Kurt TeKolste on
How about this?

randomSymmetricMatrix[dimension_Integer] := Module[{a=
Table[Join[ConstantArray[0, (i - 1)], {1/2},
Table[RandomReal[], {k, dimension - i}]], {i, dimension}]},
a+Transpose[a]]

On Wed, 24 Mar 2010 04:40 -0500, "Diamond, Mark" <dot(a)dot.dot> wrote:
> Brilliant. Thank you, both Raffy and Ray.
>
>
> "Ray Koopman" <koopman(a)sfu.ca> wrote in message
> news:ho76uf$sm$1(a)smc.vnet.net...
> > On Mar 20, 12:46 am, "Diamond, Mark" <d...(a)dot.dot> wrote:
> >> Thank you Ray.
> >>
> >> Have you any thoughts about the second question?
> >>
> >> Cheers, Mark
> >
> > In[1]:= makesymat[n_] := ToExpression["symat[" <> ToString@n <> "]
> > := Function[" <> ToString(a)Table[ Which[i > j, SequenceForm["#[[",(i-1)(i-
> > 2)/2 + j,"]]"], i < j, SequenceForm["#[[",(j-1)(j-2)/2 +
> > i,"]]"], True, "1"], {i,n},{j,n}] <> "]" ]
> >
> > In[2]:= makesymat[4]
> >
> > In[3]:= ?symat
> >
> > Global`symat
> >
> > symat[4] := {{1, #1[[1]], #1[[2]], #1[[4]]}, {#1[[1]], 1,
> > #1[[3]], #1[[5]]}, {#1[[2]], #1[[3]], 1, #1[[6]]},
> > {#1[[4]], #1[[5]], #1[[6]], 1}} &
> >
> > In[4]:= symat[4]@{a,b,c,d,e,f}
> >
> > Out[4]= {{1, a, b, d}, {a, 1, c, e}, {b, c, 1, f},
> > {d, e, f, 1}}
> >
>
>
>
>

From: Kurt TeKolste on
Or, even better,

randomSymmetricMatrix2[dimension_Integer] := Module[{a},
a = PadRight[#, dimension] & /@
Table[RandomReal[], {row, dimension}, {column, row - 1}];
a + a\[Transpose] + IdentityMatrix[dimension]]

ekt

On Sun, 02 May 2010 22:52 -0400, "Kurt TeKolste" <tekolste(a)fastmail.net>
wrote:
> How about this?
>
> randomSymmetricMatrix[dimension_Integer] := Module[{a=
> Table[Join[ConstantArray[0, (i - 1)], {1/2},
> Table[RandomReal[], {k, dimension - i}]], {i, dimension}]},
> a+Transpose[a]]
>
> On Wed, 24 Mar 2010 04:40 -0500, "Diamond, Mark" <dot(a)dot.dot> wrote:
> > Brilliant. Thank you, both Raffy and Ray.
> >
> >
> > "Ray Koopman" <koopman(a)sfu.ca> wrote in message
> > news:ho76uf$sm$1(a)smc.vnet.net...
> > > On Mar 20, 12:46 am, "Diamond, Mark" <d...(a)dot.dot> wrote:
> > >> Thank you Ray.
> > >>
> > >> Have you any thoughts about the second question?
> > >>
> > >> Cheers, Mark
> > >
> > > In[1]:= makesymat[n_] := ToExpression["symat[" <> ToString@n <> "]
> > > := Function[" <> ToString(a)Table[ Which[i > j, SequenceForm["#[[",(i-1)(i-
> > > 2)/2 + j,"]]"], i < j, SequenceForm["#[[",(j-1)(j-2)/2 +
> > > i,"]]"], True, "1"], {i,n},{j,n}] <> "]" ]
> > >
> > > In[2]:= makesymat[4]
> > >
> > > In[3]:= ?symat
> > >
> > > Global`symat
> > >
> > > symat[4] := {{1, #1[[1]], #1[[2]], #1[[4]]}, {#1[[1]], 1,
> > > #1[[3]], #1[[5]]}, {#1[[2]], #1[[3]], 1, #1[[6]]},
> > > {#1[[4]], #1[[5]], #1[[6]], 1}} &
> > >
> > > In[4]:= symat[4]@{a,b,c,d,e,f}
> > >
> > > Out[4]= {{1, a, b, d}, {a, 1, c, e}, {b, c, 1, f},
> > > {d, e, f, 1}}
> > >
> >
> >
> >
> >
>