Changeset abef005 in tol


Ignore:
Timestamp:
Oct 9, 2009, 9:09:14 AM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
eb3f09b
Parents:
99bfca9
Message:

Working with common input missing

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/stdlib/math/stat/models/bayesian/bysMcmc/bsr/gibbs/_inputMissingBlock.tol

    r99bfca9 rabef005  
    1313  // Mandatory members
    1414  //--------------------------------------------------------------------------
     15  //Classification of missing by name
     16  Set _.inputMissingDistinct;
     17  //Index of store position of each missing
     18  Set _.storeIndex;
    1519  //Input missing pairs (equation,variable)
    1620  Matrix _.tj;
    … …  
    6266  ////////////////////////////////////////////////////////////////////////////
    6367  {
    64   //WriteLn("TRACE"+_MID+" @BlockInputMissing::_buildWorkSpace 0");
     68  //WriteLn("TRACE"+_MID+" _buildWorkSpace 1 beta="<<VMat2Mat(beta));
    6569    Real    M = VRows(Z);
    6670    VMatrix b_= SubRow(beta, _.j);
    6771    Matrix  b = VMat2Mat(b_);
    68   //WriteLn("TRACE "+_MID+" draw 2 b="<<b);
     72  //WriteLn("TRACE "+_MID+" _buildWorkSpace 2 b="<<b);
    6973    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));
    7175    BysMcmc::Bsr::Gibbs::@WorkSpace.LinReg wslr =
    7276    [[
    7377      VMatrix _.Y = arm.blk::filter(si*Z) << _.prior.Y;
    74   //WriteLn("TRACE "+_MID+" draw 4 Y01="<<Y01);
    7578      VMatrix _.X = arm.blk::filter(si*B) << _.prior.X
    7679    ]];
     80  //WriteLn("TRACE "+_MID+" _buildWorkSpace 4 ");
    7781    BysMcmc::Bsr::Gibbs::@WorkSpace.LinReg _.ws := wslr;
    7882    True
    … …  
    8791  ////////////////////////////////////////////////////////////////////////////
    8892  {
     93  //WriteLn("TRACE "+_MID+" _buildWorkSpace_partial 1");
    8994    VMatrix If(VRows(_.prior.X.free)==0,
    9095    {
    … …  
    140145  //WriteLn("TRACE "+_MID+" initialize 1");
    141146  //WriteLn("TRACE "+_MID+" 7");
    142     VMatrix u = _.store;
     147    VMatrix store = _.store;
    143148    //Selecting input missing variables with left truncated prior information
    144149    Set leftConstrainedPrior.sel =
    … …  
    190195    });
    191196  //WriteLn("TRACE "+_MID+" initialize 4");
    192     Real ok = matchConstrains(u,prior.A,prior.a);
     197    Real ok = matchConstrains(store,prior.A,prior.a);
    193198  //WriteLn("TRACE "+_MID+" initialize 5");
    194199    ok
    … …  
    203208  ////////////////////////////////////////////////////////////////////////////
    204209  {
     210  //WriteLn("TRACE "+_MID+" filter 1");
    205211    If(Not(enabled), Z,
    206212    {
    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));
    209217      Z+Convert(U,"Cholmod.R.Sparse")
    210218    })
    … …  
    229237    BysMcmc::Bsr::Gibbs::@BlockInputMissing blk = [[
    230238    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 }),
    231258    //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]] })));
    233261    //Defining the block in the Markov Chain
    234262    Real _defined = define(
    235263      name,
    236       EvalSet(inputMissingBlock, Text(@BSR.MissingBlock b){ b->Name }),
     264      EvalSet(_.inputMissingDistinct, Text(Set cl){ (cl[1])->Name }),
    237265      mcmcPartialHandler,
    238266      numBlock,
    … …  
    253281    Set _.j = Traspose(Extract(inputMissingBlock, 4))[1];
    254282    //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    };
    259291    //Number of input missing prior equations
    260292    Real _.prior.M = Card(_.prior.sel);
Note: See TracChangeset for help on using the changeset viewer.