Changeset c209b7c in tol
- Timestamp:
- Oct 26, 2008, 10:51:11 AM (18 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- eaba07d
- Parents:
- 64e44a5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tol/stdlib/math/stat/models/bayesian/bysMcmc/bsr/gibbs/_stdLinearBlock.tol
r64e44a5 rc209b7c 41 41 //explicitely stored 42 42 VMatrix _.L = Rand(0,0,0,0); 43 VMatrix _.Ls = Rand(0,0,0,0); 44 //Last known valid initial point for constrained simulation 45 VMatrix _.beta0 = Rand(0,0,0,0); 43 46 //If you know that design matrix will be the same for all simulations you 44 47 //should to set this member as TRUE to avoid unneeded Cholesky … … 123 126 CholeskiFactor(XtX,"X") 124 127 }); 128 VMatrix If(_.R, _.Ls := Convert(_.L, "Cholmod.R.Sparse")); 125 129 1 126 130 }) … … 187 191 //////////////////////////////////////////////////////////////////////////// 188 192 { 189 VMatrix Ls = Convert(_.L, "Cholmod.R.Sparse");193 //WriteLn("TRACE "+_MID+" draw.constrained 1.1 Max(A*b0-a)="<<VMatMax(_.A*_.blockDef::_.store - a)); 190 194 VMatrix d = _.a - _.A*sr::nu; 191 195 VMatrix D = Tra(CholeskiSolve(_.L,_.At,"PtL")); 192 //WriteLn("TRACE "+_MID+" draw.constrained 2 check D="<<Real VMatMax(Abs(_.At-CholeskiSolve(_.L,Ls*Tra(D),"Pt")))); 193 VMatrix dif = _.blockDef::_.store-sr::nu; 194 VMatrix b0 = Tra(Tra(CholeskiSolve(_.L,dif,"P"))*Ls); 195 //WriteLn("TRACE "+_MID+" draw.constrained 3 check b0="<<Real VMatMax(Abs(dif-CholeskiSolve(_.L,b0,"LtP")))); 196 VMatrix b1 = TruncStdGaussian(D,d,b0,1, 196 VMatrix z0 = Tra(Tra(_.blockDef::_.store-sr::nu)*_.Ls); 197 //WriteLn("TRACE "+_MID+" draw.constrained 1.2 Max(D*z0-d)="<<VMatMax(D*z0 - d)); 198 VMatrix z = TruncStdGaussian(D,d,z0,1, 197 199 _.blockDef::_.config::bsr.truncMNormal.gibbsNumIter); 198 VMatrix b2 = CholeskiSolve(_.L,b1,"LtP"); 199 //WriteLn("TRACE "+_MID+" draw.constrained 4 check b2="<<Real VMatMax(Abs(b0-Tra(Tra(CholeskiSolve(_.L,b1,"P"))*Ls)))); 200 VMatrix (_.blockDef::_.store) := sr::nu+b2; 200 Real distBorder = VMatMax(D*z-d); 201 Real If(distBorder<=0, 202 { 203 VMatrix _.beta0 := _.blockDef::_.store; 204 1 205 }, 206 { 207 WriteLn(_MID+" Found a point that doesn't match constrains Max(D*z-d)="<< 208 VMatMax(D*z-d)+"\n Trying again"); 209 If(!VRows(_.beta0),0, 210 { 211 VMatrix z0 := Tra(Tra(_.beta0-sr::nu)*_.Ls); 212 VMatrix z := TruncStdGaussian(D,d,z0,1, 213 _.blockDef::_.config::bsr.truncMNormal.gibbsNumIter); 214 1 215 }); 216 1 217 }); 218 VMatrix (_.blockDef::_.store) := sr::nu + CholeskiSolve(_.L,z,"LtP"); 201 219 Copy(_.blockDef::_.store) 202 220 };
Note: See TracChangeset
for help on using the changeset viewer.
