Changeset a2a1c99 in tol
- Timestamp:
- Apr 13, 2009, 7:24:20 AM (18 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 77c3523
- Parents:
- 4ecf6014
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tol/stdlib/math/stat/models/bayesian/bysMcmc/bsr/gibbs/_estim.tol
r4ecf6014 ra2a1c99 8 8 9 9 ////////////////////////////////////////////////////////////////////////////// 10 Text _.autodoc.member. EstimParsed =11 " Estimatesa BSR model by Gibbs method\n"+10 Text _.autodoc.member.GetCyclerFromParsed = 11 "Builds the Cycler of a BSR model by Gibbs method\n"+ 12 12 "Argument `parsed` must be defined as the result of calling function " 13 13 "BSR.Parse\n"; 14 14 15 Set EstimParsed(BSR.ModelDef parsed,16 Set nonLinFilter,17 Config config,18 Notifier notifier)15 Cycler GetCyclerFromParsed(BSR.ModelDef parsed, 16 Set nonLinFilter, 17 Config config, 18 Notifier notifier) 19 19 ////////////////////////////////////////////////////////////////////////////// 20 20 { … … 29 29 BysMcmc::Bsr::Gibbs::NonLinMaster(parsed, nonLinFilter, config) 30 30 }); 31 BysMcmc::Cycler cycler = [[ Real _unused = 0 ]]; 32 Real cycler::define(sampler, notifier, config); 33 Text recover.path = cycler::_.sampler::get.path(0)+cycler::_.name+".recover.oza"; 34 NameBlock recover = 35 [[ 36 Text _.name = cycler::_.name; 37 Set _.colNames = cycler::_.sampler::get.colNames(0); 38 Set _.repCfg = cycler::bysInf_; 39 Text _.mcmc.path = cycler::_.path; 40 Real stored.simulations(Real unused) 41 { 42 Set mcmc.dim = MatReadDimensions(path); 43 mcmc.dim::Rows 44 }; 45 Set report(Real burnin, Real length, Real thinning) 46 { 47 BysMcmc::Inference::loadAndReport( 48 _.mcmc.path, burnin, length, thinning, 49 _.name, _.colNames, _.repCfg) 50 } 31 BysMcmc::Cycler cycler = [[ 32 BysMcmc::MasterSampler _.sampler = sampler; 33 BysMcmc::Notifier _.notifier = notifier; 34 BysMcmc::Config _.config = config 51 35 ]]; 52 Real Ois.Store([[recover]],recover.path); 53 54 Real cycler::initialize(0); 55 Real cycler::generate(config::mcmc.burnin+config::mcmc.sampleLength); 56 57 Real notifier::reporting(0); 58 Set estim = If(Not(config::do.report), 59 { 60 [[ 61 parsed, 62 sampler, 63 cycler 64 ]] 65 }, 66 { 67 Set report = cycler::report(config::mcmc.burnin, config::mcmc.sampleLength,config::mcmc.thinning); 68 Matrix param.average = 69 { 70 Tra(SetMat(Extract(report::coda.summary, 2))) 71 }; 72 If(!(config::do.eval), 73 { 74 [[ 75 parsed, 76 sampler, 77 cycler, 78 report, 79 param.average 80 ]] 81 }, 82 { 83 Real notifier::evaluating(0); 84 Set eval.average = sampler::eval(param.average); 85 [[ 86 parsed, 87 sampler, 88 cycler, 89 report, 90 param.average, 91 eval.average 92 ]] 93 }) 94 }); 95 Real SetIndexByName(estim); 96 estim 36 Real cycler::define(0); 37 Set Append(cycler::auxInfo, [[parsed]]); 38 //Set Append(cycler::auxInfo, [[sampler]]); 39 cycler 97 40 }; 98 /////////////////////////////////////////////////////////////////////////////99 PutDescription(_.autodoc.member.EstimParsed,EstimParsed);100 /////////////////////////////////////////////////////////////////////////////101 41 102 42 ////////////////////////////////////////////////////////////////////////////// 103 Text _.autodoc.member. EstimAscii =104 " Estimatesa BSR model by Gibbs method\n"+43 Text _.autodoc.member.GetCyclerFromAscii = 44 "Builds the Cycler of a BSR model by Gibbs method\n"+ 105 45 "Argument `ascii` must be an ASCII file path prepared to be parsed by " 106 46 "function BSR.Parse\n"; 107 Set EstimAscii(Text ascii_,108 Set nonLinFilter,109 Config config,110 Notifier notifier)47 Cycler GetCyclerFromAscii(Text ascii_, 48 Set nonLinFilter, 49 Config config, 50 Notifier notifier) 111 51 ////////////////////////////////////////////////////////////////////////////// 112 52 { … … 115 55 Real notifier::parsing(0); 116 56 Set parsed = BSR.Parse(ascii); 117 Set estim = [[ascii]] << EstimParsed(parsed,nonLinFilter,config,notifier); 118 Real SetIndexByName(estim); 119 estim 57 BysMcmc::Cycler cycler = 58 GetCyclerFromParsed(parsed,nonLinFilter,config,notifier); 59 Set Append(cycler::auxInfo, [[ascii]]); 60 cycler 120 61 }; 121 /////////////////////////////////////////////////////////////////////////////122 PutDescription(_.autodoc.member.EstimAscii,EstimAscii);123 /////////////////////////////////////////////////////////////////////////////124 62 125 63 ////////////////////////////////////////////////////////////////////////////// 126 Text _.autodoc.member. EstimAndNotify=127 " Estimatesa BSR model by Gibbs method\n"+64 Text _.autodoc.member.GetCycler = 65 "Builds the Cycler of a BSR model by Gibbs method\n"+ 128 66 "Argument `modelDef` must be one of these things: \n " 129 67 " - A Text containing an ASCII file path prepared to be parsed by " … … 132 70 " - A NameBlock with the minimum API accepted by standard importing method " 133 71 "BysMcmc::Bsr::Import::Write\n"; 134 Set EstimAndNotify(Anything modelDef,135 Config config,136 Notifier notifier)72 Cycler GetCycler(Anything modelDef, 73 Config config, 74 Notifier notifier) 137 75 ////////////////////////////////////////////////////////////////////////////// 138 76 { 139 77 Text g = Grammar(modelDef); 140 Set estim =Case78 Case 141 79 ( 142 g=="Set", EstimParsed(modelDef, Empty, config, notifier),143 g=="Text", EstimAscii (modelDef, Empty, config, notifier),80 g=="Set", GetCyclerFromParsed(modelDef, Empty, config, notifier), 81 g=="Text", GetCyclerFromAscii (modelDef, Empty, config, notifier), 144 82 g=="NameBlock", 145 83 { … … 147 85 //WriteLn("TRACE EstimAndNotify FunctionExist('Set','modelDef::Get.NonLinFilter') = "<<FunctionExist("Set","modelDef::Get.NonLinFilter")); 148 86 Set nonLinFilter = 149 If(!FunctionExist("Set","modelDef::Get.NonLinFilter"), Empty,87 If(!FunctionExist("Set","modelDef::Get.NonLinFilter"), Copy(Empty), 150 88 modelDef::Get.NonLinFilter(0)); 151 89 //WriteLn("TRACE EstimAndNotify Card(nonLinFilter) = "<<Card(nonLinFilter)); 152 [[modelDef]] << EstimAscii(ascii, nonLinFilter, config, notifier)90 GetCyclerFromAscii(ascii, nonLinFilter, config, notifier) 153 91 }, 154 92 1==1, … … 156 94 Error("Not allowd type "+g+" for argument modelDef of " 157 95 "Bsr::Gibbs::Estim"); 158 ""96 Real Stop 159 97 } 160 ); 161 Real SetIndexByName(estim); 162 estim 98 ) 163 99 }; 164 /////////////////////////////////////////////////////////////////////////////165 PutDescription(_.autodoc.member.EstimAndNotify,EstimAndNotify);166 /////////////////////////////////////////////////////////////////////////////167 168 169 //////////////////////////////////////////////////////////////////////////////170 Text _.autodoc.member.Estim =171 "Estimates a BSR model by Gibbs method\n"+172 "Argument `modelDef` must be one of these things: \n "173 " - A Text containing an ASCII file path prepared to be parsed by "174 " function BSR.Parse\n"+175 " - A Set containing the result of calling function BSR.Parse\n"+176 " - A NameBlock with the minimum API accepted by standard importing method "177 "BysMcmc::Bsr::Import::Write\n";178 Set Estim(Anything modelDef,179 Config config)180 //////////////////////////////////////////////////////////////////////////////181 {182 EstimAndNotify(modelDef, config, BysMcmc::NoNotifier(0))183 };184 /////////////////////////////////////////////////////////////////////////////185 PutDescription(_.autodoc.member.Estim,Estim);186 /////////////////////////////////////////////////////////////////////////////187
Note: See TracChangeset
for help on using the changeset viewer.
