Changeset abef005 in tol
- Timestamp:
- Oct 9, 2009, 9:09:14 AM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- eb3f09b
- Parents:
- 99bfca9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tol/stdlib/math/stat/models/bayesian/bysMcmc/bsr/gibbs/_inputMissingBlock.tol
r99bfca9 rabef005 13 13 // Mandatory members 14 14 //-------------------------------------------------------------------------- 15 //Classification of missing by name 16 Set _.inputMissingDistinct; 17 //Index of store position of each missing 18 Set _.storeIndex; 15 19 //Input missing pairs (equation,variable) 16 20 Matrix _.tj; … … 62 66 //////////////////////////////////////////////////////////////////////////// 63 67 { 64 //WriteLn("TRACE"+_MID+" @BlockInputMissing::_buildWorkSpace 0");68 //WriteLn("TRACE"+_MID+" _buildWorkSpace 1 beta="<<VMat2Mat(beta)); 65 69 Real M = VRows(Z); 66 70 VMatrix b_= SubRow(beta, _.j); 67 71 Matrix b = VMat2Mat(b_); 68 //WriteLn("TRACE "+_MID+" draw2 b="<<b);72 //WriteLn("TRACE "+_MID+" _buildWorkSpace 2 b="<<b); 69 73 VMatrix B = (Convert(Triplet(_.tk | b, M, _.N),"Cholmod.R.Sparse")); 70 //WriteLn("TRACE "+_MID+" draw 3 B="<<B);74 //WriteLn("TRACE "+_MID+" _buildWorkSpace 3 B="<<VMat2Mat(B)); 71 75 BysMcmc::Bsr::Gibbs::@WorkSpace.LinReg wslr = 72 76 [[ 73 77 VMatrix _.Y = arm.blk::filter(si*Z) << _.prior.Y; 74 //WriteLn("TRACE "+_MID+" draw 4 Y01="<<Y01);75 78 VMatrix _.X = arm.blk::filter(si*B) << _.prior.X 76 79 ]]; 80 //WriteLn("TRACE "+_MID+" _buildWorkSpace 4 "); 77 81 BysMcmc::Bsr::Gibbs::@WorkSpace.LinReg _.ws := wslr; 78 82 True … … 87 91 //////////////////////////////////////////////////////////////////////////// 88 92 { 93 //WriteLn("TRACE "+_MID+" _buildWorkSpace_partial 1"); 89 94 VMatrix If(VRows(_.prior.X.free)==0, 90 95 { … … 140 145 //WriteLn("TRACE "+_MID+" initialize 1"); 141 146 //WriteLn("TRACE "+_MID+" 7"); 142 VMatrix u= _.store;147 VMatrix store = _.store; 143 148 //Selecting input missing variables with left truncated prior information 144 149 Set leftConstrainedPrior.sel = … … 190 195 }); 191 196 //WriteLn("TRACE "+_MID+" initialize 4"); 192 Real ok = matchConstrains( u,prior.A,prior.a);197 Real ok = matchConstrains(store,prior.A,prior.a); 193 198 //WriteLn("TRACE "+_MID+" initialize 5"); 194 199 ok … … 203 208 //////////////////////////////////////////////////////////////////////////// 204 209 { 210 //WriteLn("TRACE "+_MID+" filter 1"); 205 211 If(Not(enabled), Z, 206 212 { 207 Matrix tr = _.tj | VMat2Mat(_.store); 208 VMatrix U =Triplet(tr,VRows(Z),VColumns(Z)); 213 //WriteLn("TRACE "+_MID+" filter 2"); 214 VMatrix u = SubRow(_.store, _.storeIndex); 215 Matrix tr = _.tj | VMat2Mat(u); 216 VMatrix U = Triplet(tr,VRows(Z),VColumns(Z)); 209 217 Z+Convert(U,"Cholmod.R.Sparse") 210 218 }) … … 229 237 BysMcmc::Bsr::Gibbs::@BlockInputMissing blk = [[ 230 238 Code _.buildWorkSpace = _buildWorkSpace; 239 Set _.inputMissingDistinct = 240 { 241 Set aux = Classify(inputMissingBlock, 242 Real(@BSR.MissingBlock a, @BSR.MissingBlock b) 243 { 244 Compare(a->Name, b->Name) 245 }); 246 Set For(1, Card(aux), Real(Real k) 247 { 248 Set EvalSet(aux[k], Real(@BSR.MissingBlock mis) 249 { 250 Real mis->Index := k 251 }); 252 k 253 }); 254 aux 255 }; 256 Set _.storeIndex = EvalSet(inputMissingBlock, 257 Real(@BSR.MissingBlock mis){ mis->Index }), 231 258 //Given initial values of block variables 232 VMatrix _.store = Mat2VMat(SetMat(Extract(inputMissingBlock, 6))); 259 VMatrix _.store = Mat2VMat(SetMat( 260 EvalSet(_.inputMissingDistinct, Set(Set cl){ [[(cl[1])->Nu]] }))); 233 261 //Defining the block in the Markov Chain 234 262 Real _defined = define( 235 263 name, 236 EvalSet( inputMissingBlock, Text(@BSR.MissingBlock b){ b->Name }),264 EvalSet(_.inputMissingDistinct, Text(Set cl){ (cl[1])->Name }), 237 265 mcmcPartialHandler, 238 266 numBlock, … … 253 281 Set _.j = Traspose(Extract(inputMissingBlock, 4))[1]; 254 282 //Selecting input missing variables with prior information 255 Set _.prior.sel = Select(inputMissingBlock, Real(@BSR.MissingBlock b) 256 { 257 b->Prior != "None" 258 }); 283 Set _.prior.sel = 284 { 285 Set aux = EvalSet(_.inputMissingDistinct, Set(Set cl){ cl[1] }); 286 Select(aux, Real(@BSR.MissingBlock b) 287 { 288 b->Prior != "None" 289 }) 290 }; 259 291 //Number of input missing prior equations 260 292 Real _.prior.M = Card(_.prior.sel);
Note: See TracChangeset
for help on using the changeset viewer.
