MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: correlated random vector

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63938] Re: correlated random vector
  • From: "Valeri Astanoff" <astanoff at yahoo.fr>
  • Date: Tue, 24 Jan 2006 01:30:23 -0500 (EST)
  • References: <dqsp65$cbj$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

This is my way to do it (just an example) :


In[1]:=<<Statistics`

In[2]:=
unif[data_List, corr_?NumericQ]:=
    Module[{n,data2,x,co,seq,fm},
      n = Length[data];
      data2 = data+Table[a*i+x[i],{i,1,n}];
      co = Correlation[data,data2];
      seq = Append[Table[{x[i],Random[]},{i,1,n}],{a,0}];
      fm = Last@FindMinimum[(co-corr)^2,seq];
      data2 /. fm
      ];

In[3]:=data=Table[5+Random[],{20}]

Out[3]=
{5.39226,5.36703,5.31962,5.16276,5.12001,
5.55116,5.20296,5.40329,5.09581,5.19278,
5.03282,5.04554,5.63755,5.71108,5.95834,
5.25023,5.30043,5.31474,5.54467,5.24328}

In[4]:=data2=unif[data,0.6]

Out[4]=
{5.47602,5.99265,5.84691,5.46308,5.89896,
5.8935,5.49545,5.62488,5.83973,6.07133,
6.20991,5.95155,6.36889,6.47994,7.18477,
6.19511,6.48132,6.45963,6.89937,6.02256}

In[5]:=Correlation[data,data2]

Out[5]=0.6

Sure this doesn't work in all experimental cases,
but it might inspire you for a better approach. 


v.a.


  • Prev by Date: Re: show workings
  • Next by Date: Re: how to define a constant like Pi in Mathematica
  • Previous by thread: correlated random vector
  • Next by thread: Re: correlated random vector