Changeset 901aaa9 in tol


Ignore:
Timestamp:
Apr 13, 2010, 5:32:52 PM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
e613e67
Parents:
a30612b
Message:

Fixed bug in single try

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@2092 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol_tests/tol/ARIMA/mcmc/mtrymh.tol

    ra30612b r901aaa9  
    159159    VMatrix y = Q_draw(_.x);
    160160    Real pi_logDens_y = pi_logDens(y);
     161    Real _.pi_logDens_x := pi_logDens(_.x);
    161162    Real _.r := Min(1, If(_.simetricQ,
    162163    {
    … …  
    167168          (_.pi_logDens_x + Q_logDens(_.x,   y)) )
    168169    }));
    169     Real If(accept_reject(y), _.pi_logDens_x := pi_logDens_y);
     170    Real accept_reject(y);
    170171    _.x
    171172  };
    … …  
    225226      Y[j]
    226227    };
    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));
    229230    Set X = For(1,_.k-1, VMatrix X_Q_draw(Real j) { Q_draw(y) }) << [[_.x]];
    230 
    231231    Real calc_denominator_Xjy(Real void)
    232232    {
    233     //WriteLn("TRACE draw pi_matchesDomain(y)="<<pi_matchesDomain(y));
    234233      VMatrix lwXjy := Mat2VMat(SetCol(For(1,_.k, Real(Real j)
    235234      {
    … …  
    242241      VMatrix gXjy = Exp(lwXjy-lwXjy_max);
    243242      Real gXjy_sum := VMatSum(gXjy);
     243    //WriteLn("TRACE draw gXjy_sum=\n"<<gXjy_sum);
    244244      True
    245245    };
    246246    Real calc_denominator_Xjy(0);
    247247
    248     //WriteLn("TRACE draw gXjy_sum=\n"<<gXjy_sum);
    249248    Real _.r := Min(1,Exp(lwYjx_max-lwXjy_max)*(gYjx_sum/gXjy_sum));
    250249  //WriteLn("TRACE draw _.r=\n"<<_.r);
    251250    Real accept_reject(y);
    252     y
    253   })}
     251    _.x
     252  }) }
    254253};
    255254
    … …  
    616615  ////////////////////////////////////////////////////////////////////////////
    617616  {
     617/* * /
     618    Real pi_logDens_x = _.pi_logDens_x;
    618619    VMatrix x = _.x;
    619     Real pi_logDens_x = _.pi_logDens_x;
    620 /*
    621620    Matrix Y = Group("ConcatRows", For(1,maxIter,Matrix(Real iter)
    622621    {
    … …  
    637636      Copy(VMat2Mat(Tra(x)))
    638637    }));
    639 */
     638/* */
    640639    Matrix pi_logDens_y = Rand(1,maxIter,0,0);
    641640    Matrix Y = Group("ConcatRows", For(1,maxIter,Matrix(Real iter)
    … …  
    643642      VMatrix y = arima2col(RandCopyARIMA(_.arima));
    644643      Real PutMatDat(pi_logDens_y, 1, iter, pi_logDens(y));
    645       Copy(VMat2Mat(Tra(x)))
     644      Copy(VMat2Mat(Tra(y)))
    646645    }));
    647646    Real pi_logDens_max = MatMax(pi_logDens_y);
    … …  
    649648    Matrix g = w * (1/MatSum(w));
    650649    VMatrix _.x := Mat2VMat(Tra(g*Y));
    651     Real _.pi_logDens_x := pi_logDens_x;
     650    Real _.pi_logDens_x := pi_logDens(_.x);
    652651    Real doAfterDraw(0);
     652/* */
    653653    Y
    654654  }
    … …  
    656656};
    657657
     658Real PutRandomSeed(0);
     659Real rndSeed_iv = GetRandomSeed(0);
     660WriteLn("Current Random Seed for initial values= "<<rndSeed_iv);
    658661
    659662@MTryMetropolis_ARIMA mtm_arima = @MTryMetropolis_ARIMA::New(
    … …  
    671674/* */
    672675
    673 Real mtm_arima::_.k := Ceil((mtm_arima::_.n));
     676Real mtm_arima::_.k := 9; //Ceil(Sqrt(mtm_arima::_.n));
    674677
    675678Matrix mcmc = Rand(0,mtm_arima::_.n,0,0);
    … …  
    677680Real mtm_arima::_.s := 0.01;
    678681
    679 //Matrix m2avr = mtm_arima::move_to_average(Round(500*Sqrt(mtm_arima::_.n)));
     682/*
     683Real m2avr.numSim = 500;
     684Real m2avr.t0 = Copy(Time);
     685Matrix m2avr = mtm_arima::move_to_average(m2avr.numSim);
     686Real m2avr.time = (Copy(Time) - m2avr.t0)/m2avr.numSim;
     687WriteLn("Time by AVR estimation "<<m2avr.time);
     688*/
    680689
    681690Real numSim = 0;
    … …  
    683692Real append_draw(VMatrix draw)
    684693{
    685   If(!(numSim%10), WriteLn("
     694  If(!(numSim%100), WriteLn("
    686695##############################################################################
    687696Simulation "<<numSim+ " _.acceptRatio="<<mtm_arima::_.acceptRatio));
    … …  
    699708
    700709/* */
    701 Real mtm_arima::_.sFactor := 1.0;
     710Real mtm_arima::_.sFactor := 1.00;
    702711Real numSim := 0;
    703712Real mtm.t0 = Copy(Time);
    704713Real TolOprProfiler.Enabled := True;
    705714While(numSim<2500, append_draw(mtm_arima::draw_multiple_try(0)));
    706 Real TolOprProfiler.Dump("draw_multiple_try.csv");
     715Real TolOprProfiler.Dump("draw_multiple_try.k"<<mtm_arima::_.k+".csv");
    707716Real mtm.time = (Copy(Time) - mtm.t0)/numSim;
    708717WriteLn("Time by MTM simulation "<<mtm.time);
Note: See TracChangeset for help on using the changeset viewer.