Changeset 901aaa9 in tol
- Timestamp:
- Apr 13, 2010, 5:32:52 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- e613e67
- Parents:
- a30612b
- File:
-
- 1 edited
-
tol_tests/tol/ARIMA/mcmc/mtrymh.tol (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol_tests/tol/ARIMA/mcmc/mtrymh.tol
ra30612b r901aaa9 159 159 VMatrix y = Q_draw(_.x); 160 160 Real pi_logDens_y = pi_logDens(y); 161 Real _.pi_logDens_x := pi_logDens(_.x); 161 162 Real _.r := Min(1, If(_.simetricQ, 162 163 { … … 167 168 (_.pi_logDens_x + Q_logDens(_.x, y)) ) 168 169 })); 169 Real If(accept_reject(y), _.pi_logDens_x := pi_logDens_y);170 Real accept_reject(y); 170 171 _.x 171 172 }; … … 225 226 Y[j] 226 227 }; 227 VMatrix y = draw_y(0);228 228 VMatrix y = If(_.k==1,Y[1],draw_y(0)); 229 //WriteLn("TRACE draw pi_matchesDomain(y)="<<pi_matchesDomain(y)); 229 230 Set X = For(1,_.k-1, VMatrix X_Q_draw(Real j) { Q_draw(y) }) << [[_.x]]; 230 231 231 Real calc_denominator_Xjy(Real void) 232 232 { 233 //WriteLn("TRACE draw pi_matchesDomain(y)="<<pi_matchesDomain(y));234 233 VMatrix lwXjy := Mat2VMat(SetCol(For(1,_.k, Real(Real j) 235 234 { … … 242 241 VMatrix gXjy = Exp(lwXjy-lwXjy_max); 243 242 Real gXjy_sum := VMatSum(gXjy); 243 //WriteLn("TRACE draw gXjy_sum=\n"<<gXjy_sum); 244 244 True 245 245 }; 246 246 Real calc_denominator_Xjy(0); 247 247 248 //WriteLn("TRACE draw gXjy_sum=\n"<<gXjy_sum);249 248 Real _.r := Min(1,Exp(lwYjx_max-lwXjy_max)*(gYjx_sum/gXjy_sum)); 250 249 //WriteLn("TRACE draw _.r=\n"<<_.r); 251 250 Real accept_reject(y); 252 y253 }) }251 _.x 252 }) } 254 253 }; 255 254 … … 616 615 //////////////////////////////////////////////////////////////////////////// 617 616 { 617 /* * / 618 Real pi_logDens_x = _.pi_logDens_x; 618 619 VMatrix x = _.x; 619 Real pi_logDens_x = _.pi_logDens_x;620 /*621 620 Matrix Y = Group("ConcatRows", For(1,maxIter,Matrix(Real iter) 622 621 { … … 637 636 Copy(VMat2Mat(Tra(x))) 638 637 })); 639 */638 /* */ 640 639 Matrix pi_logDens_y = Rand(1,maxIter,0,0); 641 640 Matrix Y = Group("ConcatRows", For(1,maxIter,Matrix(Real iter) … … 643 642 VMatrix y = arima2col(RandCopyARIMA(_.arima)); 644 643 Real PutMatDat(pi_logDens_y, 1, iter, pi_logDens(y)); 645 Copy(VMat2Mat(Tra( x)))644 Copy(VMat2Mat(Tra(y))) 646 645 })); 647 646 Real pi_logDens_max = MatMax(pi_logDens_y); … … 649 648 Matrix g = w * (1/MatSum(w)); 650 649 VMatrix _.x := Mat2VMat(Tra(g*Y)); 651 Real _.pi_logDens_x := pi_logDens _x;650 Real _.pi_logDens_x := pi_logDens(_.x); 652 651 Real doAfterDraw(0); 652 /* */ 653 653 Y 654 654 } … … 656 656 }; 657 657 658 Real PutRandomSeed(0); 659 Real rndSeed_iv = GetRandomSeed(0); 660 WriteLn("Current Random Seed for initial values= "<<rndSeed_iv); 658 661 659 662 @MTryMetropolis_ARIMA mtm_arima = @MTryMetropolis_ARIMA::New( … … 671 674 /* */ 672 675 673 Real mtm_arima::_.k := Ceil((mtm_arima::_.n));676 Real mtm_arima::_.k := 9; //Ceil(Sqrt(mtm_arima::_.n)); 674 677 675 678 Matrix mcmc = Rand(0,mtm_arima::_.n,0,0); … … 677 680 Real mtm_arima::_.s := 0.01; 678 681 679 //Matrix m2avr = mtm_arima::move_to_average(Round(500*Sqrt(mtm_arima::_.n))); 682 /* 683 Real m2avr.numSim = 500; 684 Real m2avr.t0 = Copy(Time); 685 Matrix m2avr = mtm_arima::move_to_average(m2avr.numSim); 686 Real m2avr.time = (Copy(Time) - m2avr.t0)/m2avr.numSim; 687 WriteLn("Time by AVR estimation "<<m2avr.time); 688 */ 680 689 681 690 Real numSim = 0; … … 683 692 Real append_draw(VMatrix draw) 684 693 { 685 If(!(numSim%10 ), WriteLn("694 If(!(numSim%100), WriteLn(" 686 695 ############################################################################## 687 696 Simulation "<<numSim+ " _.acceptRatio="<<mtm_arima::_.acceptRatio)); … … 699 708 700 709 /* */ 701 Real mtm_arima::_.sFactor := 1.0 ;710 Real mtm_arima::_.sFactor := 1.00; 702 711 Real numSim := 0; 703 712 Real mtm.t0 = Copy(Time); 704 713 Real TolOprProfiler.Enabled := True; 705 714 While(numSim<2500, append_draw(mtm_arima::draw_multiple_try(0))); 706 Real TolOprProfiler.Dump("draw_multiple_try. csv");715 Real TolOprProfiler.Dump("draw_multiple_try.k"<<mtm_arima::_.k+".csv"); 707 716 Real mtm.time = (Copy(Time) - mtm.t0)/numSim; 708 717 WriteLn("Time by MTM simulation "<<mtm.time);
Note: See TracChangeset
for help on using the changeset viewer.
