Changeset e9469de4 in tol
- Timestamp:
- Mar 27, 2009, 10:32:20 AM (18 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 44ae460
- Parents:
- 76ecf8e
- Location:
- tol/stdlib/math/stat/models/bayesian/bysMcmc/bsr/gibbs
- Files:
-
- 4 edited
-
_basicMaster.tol (modified) (1 diff)
-
_inputMissingBlock.tol (modified) (1 diff)
-
_outputMissingBlock.tol (modified) (1 diff)
-
_stdLinearBlock.tol (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol/stdlib/math/stat/models/bayesian/bysMcmc/bsr/gibbs/_basicMaster.tol
r76ecf8e re9469de4 264 264 //WriteLn("TRACE"+_MID+" draw.sig.lin 8"); 265 265 VMatrix _.beta := If(Not(_.lin.blk::_.blockDef::_.numCol),Rand(0,1,0,0), 266 _.lin.blk::draw(numSim, Y01, X01)); 266 { 267 Real _.lin.blk::solve(numSim, Y01, X01); 268 _.lin.blk::draw(numSim, Y01, X01) 269 }); 267 270 //WriteLn("TRACE"+_MID+" draw.sig.lin 9"); 268 271 _.beta << sig << arm << im << om -
tol/stdlib/math/stat/models/bayesian/bysMcmc/bsr/gibbs/_inputMissingBlock.tol
r76ecf8e re9469de4 210 210 { 211 211 NameBlock ls = buildLinearSystem(arima,si,beta,Z); 212 Real _.lin.blk::solve(numSim, ls::Y01, ls::X01); 212 213 VMatrix _.blockDef::_.store := _.lin.blk::draw(numSim, ls::Y01, ls::X01); 213 214 _.blockDef::_.store -
tol/stdlib/math/stat/models/bayesian/bysMcmc/bsr/gibbs/_outputMissingBlock.tol
r76ecf8e re9469de4 191 191 { 192 192 NameBlock ls = buildLinearSystem(arima,si,Z); 193 Real _.lin.blk::solve(numSim, ls::Y01, ls::X01); 193 194 VMatrix _.blockDef::_.store := _.lin.blk::draw(numSim, ls::Y01, ls::X01); 194 195 _.blockDef::_.store -
tol/stdlib/math/stat/models/bayesian/bysMcmc/bsr/gibbs/_stdLinearBlock.tol
r76ecf8e re9469de4 56 56 //Matrix of linear system in last iteration 57 57 VMatrix _old.X = Rand(0,0,0,0); 58 // 59 Set _.solution = Copy(Empty); 60 58 61 Real _changed.X = True; 59 62 … … 64 67 //Current maximum of rounding error in solution 65 68 Real _.cholSolMaxRoundErr = 0; 69 70 //Stores the associated drawing method 71 Code _drawer = UnknownCode; 66 72 67 73 //////////////////////////////////////////////////////////////////////////// … … 189 195 //////////////////////////////////////////////////////////////////////////// 190 196 //Solves the linear system corresponding to the standarized linear regression 191 NameBlocksolve(Real numSim, VMatrix Y, VMatrix X)197 Real solve(Real numSim, VMatrix Y, VMatrix X) 192 198 //////////////////////////////////////////////////////////////////////////// 193 199 { … … 221 227 }); 222 228 //WriteLn("TRACE "+_MID+" solve 8"); 223 NameBlock [[ XtY, nu, err ]] 229 Set _.solution := [[ numSim, Y, X, XtY, nu, err ]]; 230 Real SetIndexByName(_.solution); 231 1 224 232 }; 225 233 … … 227 235 Text _.autodoc.member.draw.unconstrained = 228 236 "Method of generation of a linear block in unconstrained case"; 229 VMatrix draw.unconstrained(Real numSim , VMatrix Y, VMatrix X, NameBlock sr)237 VMatrix draw.unconstrained(Real numSim) 230 238 //////////////////////////////////////////////////////////////////////////// 231 239 { … … 236 244 //WriteLn("TRACE "+_MID+" draw.unconstrained 4 _.L="<<Matrix(VMat2Mat(_.L))); 237 245 //WriteLn("TRACE "+_MID+" draw.unconstrained 4 b2="<<Matrix(VMat2Mat(Tra(b2)))); 238 VMatrix (_.blockDef::_.store) := sr::nu+b2;246 VMatrix (_.blockDef::_.store) := _.solution::nu+b2; 239 247 //WriteLn("TRACE "+_MID+" draw.unconstrained 5"); 240 248 Copy(_.blockDef::_.store) … … 244 252 Text _.autodoc.member.draw.constrained = 245 253 "Method of generation of a linear block in constrained case"; 246 VMatrix draw.constrained(Real numSim, VMatrix Y, VMatrix X, NameBlock sr) 247 //////////////////////////////////////////////////////////////////////////// 248 { 254 VMatrix draw.constrained(Real numSim) 255 //////////////////////////////////////////////////////////////////////////// 256 { 257 VMatrix nu = _.solution::nu; 249 258 //WriteLn("TRACE "+_MID+" draw.constrained 1.1 Max(A*b0-a)="<<VMatMax(_.A*_.blockDef::_.store - a)); 250 VMatrix d = _.a - _.A* sr::nu;259 VMatrix d = _.a - _.A*nu; 251 260 VMatrix If(_changed.X, _.D := Tra(CholeskiSolve(_.L,_.At,"PtL"))); 252 VMatrix z0 = Tra(Tra(_.blockDef::_.store- sr::nu)*_.Ls);261 VMatrix z0 = Tra(Tra(_.blockDef::_.store-nu)*_.Ls); 253 262 //WriteLn("TRACE "+_MID+" draw.constrained 1.2 Max(D*z0-d)="<<VMatMax(_.D*z0 - d)); 254 263 VMatrix z = TruncStdGaussian(_.D,d,z0,1, … … 265 274 If(!VRows(_.beta0),0, 266 275 { 267 VMatrix z0 := Tra(Tra(_.beta0- sr::nu)*_.Ls);276 VMatrix z0 := Tra(Tra(_.beta0-nu)*_.Ls); 268 277 VMatrix z := TruncStdGaussian(_.D,d,z0,1, 269 278 _.blockDef::_.config::bsr.truncMNormal.gibbsNumIter); … … 272 281 1 273 282 }); 274 VMatrix (_.blockDef::_.store) := sr::nu + CholeskiSolve(_.L,z,"LtP");283 VMatrix (_.blockDef::_.store) := nu + CholeskiSolve(_.L,z,"LtP"); 275 284 Copy(_.blockDef::_.store) 276 285 }; 277 278 Code _drawer = draw.constrained;279 286 280 287 //////////////////////////////////////////////////////////////////////////// … … 286 293 If(_.blockDef::enabled, 287 294 { 288 NameBlock sr =solve(numSim,Y,X);289 VMatrix aux = _drawer(numSim , Y, X, sr);295 //Real solve(numSim,Y,X); 296 VMatrix aux = _drawer(numSim); 290 297 //WriteLn("TRACE "+_MID+" draw"); 291 298 Real _.blockDef::checkNonFiniteValues(numSim); … … 303 310 //////////////////////////////////////////////////////////////////////////// 304 311 { 305 NameBlock sr = solve(numSim,Y,X); 306 //WriteLn("TRACE "+_MID+" maxLikelihood sr::nu="<<Matrix(Tra(VMat2Mat(sr::nu)))); 312 Real solve(numSim,Y,X); 307 313 VMatrix aux = If(!_.R, 308 314 { 309 sr::nu315 _.solution::nu 310 316 }, 311 317 { 312 VMatrix d = _.a - _.A* sr::nu;313 If(VMatMax(d)>=0, sr::nu,318 VMatrix d = _.a - _.A*_.solution::nu; 319 If(VMatMax(d)>=0, _.solution::nu, 314 320 { 315 321 WriteLn("Cannot do maxLikelihood for constrained linear block "+ 316 322 _.blockDef::_.name,"W"); 317 draw.constrained(numSim , Y, X, sr)323 draw.constrained(numSim) 318 324 }) 319 325 });
Note: See TracChangeset
for help on using the changeset viewer.
