Changeset 37f35e3 in tol


Ignore:
Timestamp:
May 10, 2010, 12:49:21 PM (16 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
c2d5affd
Parents:
00672de
Message:

Refs #902
Checked multivariant linear model wit known covariance matrix

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@2143 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol_pkg/BysVecLinReg/Multivariant.tol

    r00672de r37f35e3  
    7373  VMatrix _.VxIm.Lf = Rand(0,0,0,0);
    7474  //Choleski decomposition of VxIm as sparse explicit((d*m)x(d*m))
    75   VMatrix _.VxIm.Ls = Rand(0,0,0,0);
     75  VMatrix _.VxIm.Le = Rand(0,0,0,0);
    7676 
    7777  ////////////////////////////////////////////////////////////////////////////
    78   VMatrix vmatrix2vec(VMatrix M)
     78  Static VMatrix vmatrix2vec(VMatrix M)
    7979  ////////////////////////////////////////////////////////////////////////////
    8080  {
    … …  
    8484
    8585  ////////////////////////////////////////////////////////////////////////////
    86   VMatrix vec2vmatrix(VMatrix vec, VMatrix M)
     86  Static VMatrix vec2vmatrix(VMatrix vec, VMatrix M)
    8787  ////////////////////////////////////////////////////////////////////////////
    8888  {
    8989    Matrix Mt = VMat2Mat(M,True);
    90     Mat2VMat(DeepCopy([[Mt]],vec)[1])
     90    Mat2VMat(DeepCopy([[Mt]],VMat2Mat(vec))[1],True)
    9191  };
    9292
    … …  
    177177      VMatrix _.X.Le := CholeskiSolve(_.X.Lf,
    178178        Convert(_.X.Lf, "Cholmod.R.Sparse"),"P");
    179       VMatrix _.X.Li := CholeskiSolve(_.X.Lf,Eye(_.m),"PtLLtP");
     179      VMatrix _.X.Li := CholeskiSolve(_.X.Lf,Eye(_.m),"PtL");
    180180      VMatrix _.IdxXL := KroneckerProduct(Eye(_.d),_.X.Le);
    181181      VMatrix _.IdxXLi := KroneckerProduct(Eye(_.d),_.X.Li);
    … …  
    194194      VMatrix XYt =_.X*Tra(_.Y);
    195195      VMatrix _.nu:=Tra(CholeskiSolve(_.X.Lf,XYt,"PtLLtP"));
    196       VMatrix _.nuXYt = _.nu*XYt;
    197       VMatrix _.vec.nu:=vmatrix2vec(_.nu);
     196      VMatrix _.nuXYt := _.nu*XYt;
     197      VMatrix _.vec.nu:=@Multivariant::vmatrix2vec(_.nu);
    198198      True
    199199    })
    … …  
    212212    {
    213213      Real _.alpha := alpha;
    214       VMatrix _.Sy.x = _.YYt - _.nuXYt/(1+_.alpha);
     214      VMatrix _.Sy.x := _.YYt - _.nuXYt/(1+_.alpha);
    215215      True
    216216    })
    … …  
    225225      VMatrix _.V := Copy(V);
    226226      VMatrix _.VxIm := KroneckerProduct(_.V, Eye(_.m));
    227       VMatrix _.VxIm.Lf := CholeskiSolve(_.VxIm,"X");
     227      VMatrix _.VxIm.Lf := CholeskiFactor(_.VxIm,"X");
    228228      VMatrix _.VxIm.Le := CholeskiSolve(_.VxIm.Lf,
    229229        Convert(_.VxIm.Lf, "Cholmod.R.Sparse"),"P");
    230       VMatrix _.VxIm.Lf := CholeskiSolve(_.VxIm,"X");
     230      VMatrix _.VxIm.Lf := CholeskiFactor(_.VxIm,"X");
    231231      VMatrix _.VxIm.Le := CholeskiSolve(_.VxIm.Lf,
    232232        Convert(_.VxIm.Lf, "Cholmod.R.Sparse"),"P");
    … …  
    255255
    256256  ////////////////////////////////////////////////////////////////////////////
     257  VMatrix gibbs.draw.vec.A(Real numSim)
     258  ////////////////////////////////////////////////////////////////////////////
     259  {
     260    VMatrix e = Gaussian(_.d*_.m,1,0,1);
     261    VMatrix e.1 = _.VxIm.Le*e;
     262    VMatrix e.2 = Tra(Tra(e.1)*_.IdxXLi);
     263    VMatrix _.vec.A := (_.vec.nu + e.2)/(1+_.alpha);
     264    _.vec.A
     265  };
     266
     267  ////////////////////////////////////////////////////////////////////////////
    257268  VMatrix gibbs.draw.A(Real numSim)
    258269  ////////////////////////////////////////////////////////////////////////////
    259270  {
    260     VMatrix e = Gaussian(_.d*_.m_,1,0,1);
    261     VMatrix e.1 = _.VxIm.Le*e;
    262     VMatrix e.2 = _.IdxXLi*e.1;
    263     VMatrix _.vec.A := (_.vec.nu + e.2)/(1+_.alpha);
    264     VMatrix _.A := vec2vmatrix(_.vec.a);
     271    VMatrix gibbs.draw.vec.A(numSim);
     272    VMatrix _.A := @Multivariant::vec2vmatrix(_.vec.a);
    265273    Copy(_.A)
    266   };
    267 
    268   ////////////////////////////////////////////////////////////////////////////
    269   VMatrix gibbs.draw(Real numSim)
    270   ////////////////////////////////////////////////////////////////////////////
    271   {
    272     _.vec.A
    273274  }
     275
    274276}
    275277
Note: See TracChangeset for help on using the changeset viewer.