﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
444	Problems with MatSerSet	César Pérez Álvarez	Víctor de Buen Remiro	"If we run this code:


//////////////////////////////////////////////////////////////////////////////
Serie EstimCensoredData
(
  Serie ser,
  Serie top, 
  Serie filter,
  Real sigma
)
//////////////////////////////////////////////////////////////////////////////
{
  Serie indCensoredData = EQ(ser, top);
  
  Date first   = FirstNotEqual(ser, First(ser), 0);
  TimeSet auto = SerTms(indCensoredData);

  Serie filterAuto    = DatCh(filter, auto, FirstS);
  Serie filterAutoSub = SubSer(filterAuto, first, Last(filterAuto));

  Serie topAuto       = DatCh(top, auto, FirstS);
  Serie topAutoSub    = SubSer(topAuto, first, Last(filterAuto));
 
  Matrix mFilterAuto = Tra(SerMat(filterAutoSub));
  Matrix mTopAuto    = Tra(SerMat(topAutoSub));

  Real n             = Rows(mFilterAuto);
  Matrix lCovBeta    = Diag(n, sigma);
  Matrix limInf      = mTopAuto; 
  Matrix limSup      = Rand(n, 1, TheMaxAbsValue, TheMaxAbsValue); 

  Matrix censored    = 
   RandTruncatedMultNormal(mFilterAuto, lCovBeta, limInf, limSup, 1, 1);
  Set setCensored = MatSerSet(Tra(censored), auto, first);
  IfSer(indCensoredData, InvCh(setCensored[1], CalInd(W, Diario)), ser)
};
//////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
//////////////////////////////////////////////////////////////////////////////

Serie top    = 199*CalInd(C,Diario);
Serie serAux = SubSer(top-Gaussian(10, 10, Diario), y2004m01d01, y2006m02d01);
Serie ser    = IfSer(GT(top, serAux), serAux,top);

Serie filter = AvrS(ser)*CalInd(C,Diario);
Real sigma = StDsS(serAux); 


Serie final = EstimCensoredData(ser, top, filter,sigma);


And now if we try to tabulate the final time series then TOL crashes.
However in this code the things run correctly:

Serie top    = 199*CalInd(C,Diario);
Serie serAux = SubSer(top-Gaussian(10, 10, Diario), y2004m01d01, y2006m02d01);
Serie ser    = IfSer(GT(top, serAux), serAux,top);

Serie filter = AvrS(ser)*CalInd(C,Diario);
Real sigma = StDsS(serAux); 


  Serie indCensoredData = EQ(ser, top);
  
  Date first   = FirstNotEqual(ser, First(ser), 0);
  TimeSet auto = SerTms(indCensoredData);

  Serie filterAuto    = DatCh(filter, auto, FirstS);
  Serie filterAutoSub = SubSer(filterAuto, first, Last(filterAuto));

  Serie topAuto       = DatCh(top, auto, FirstS);
  Serie topAutoSub    = SubSer(topAuto, first, Last(filterAuto));
 
  Matrix mFilterAuto = Tra(SerMat(filterAutoSub));
  Matrix mTopAuto    = Tra(SerMat(topAutoSub));

  Real n             = Rows(mFilterAuto);
  Matrix lCovBeta    = Diag(n, sigma);
  Matrix limInf      = mTopAuto; 
  Matrix limSup      = Rand(n, 1, TheMaxAbsValue, TheMaxAbsValue); 

  Matrix censored    = 
   RandTruncatedMultNormal(mFilterAuto, lCovBeta, limInf, limSup, 1, 1);
  Set setCensored = MatSerSet(Tra(censored), auto, first);
  Serie final = IfSer(indCensoredData, InvCh(setCensored[1], CalInd(W, Diario)), ser)


Another last thing: if we return a Set function instead of a Serie function putting a MatSerSet and we tabulate the series inside the things go right."	defect	closed	highest		SetAlgebra	head	blocker	fixed		
