close Warning: Can't synchronize with repository "(default)" (/var/svn/tolp does not appear to be a Subversion repository.). Look in the Trac log for more information.

Opened 16 years ago

Closed 16 years ago

#706 closed doubt (fixed)

Why Expand function for Series does not handle unknown values (?) ?

Reported by: Alfredo Torre Owned by: Víctor de Buen Remiro
Priority: normal Milestone: Mantainance
Component: Kernel Version: 1.1.7
Severity: normal Keywords: Expand, unknown values
Cc:

Description

Why Expand function for Series does not work when I try to Expand unknown values? I can use ExpandOmit function (from StdLib) but I don't trust in that function too match...

Please see this example:

Serie Ser01.Mon = SubSer(CalVar(C, Monthly), y2008, y2011);
Serie Ser01.Dai = InvCh(Ser01.Mon, Log(CalInd(W, Daily)));
Serie Ser01.Dai.Expand = Expand(Ser01.Dai, ?);
Serie Ser01.Dai.ExpandOmit = ExpandOmit(Ser01.Dai);

Change History (4)

comment:1 Changed 16 years ago by Víctor de Buen Remiro

Status: newassigned

The problem is the logic behind unknown values.

The description of function Serie Expand(Serie s) tells :

Transform a series through the replacement of each equal value to x by the last different value of x.

Both operations ? == ? and ? != ? return ?, due you don't know if an unknow value is equal or not to other unknown value. Symbol ? is not a real value. So there are no value on original series being equal to ?.

We can modify internal logic of boolean operators with unknown values, but it could originate backward incompatibilities and unexpected secondary effects, or we can change the behaviour only for this function.

I didn't know existence of ExpandOmit but reading the code you can see that it is replacing unknown values by 123456789. It would be more robust to get a value that cannot be present in original series, as { MaxS(ser)*1.01) } but the idea is good.

comment:2 Changed 16 years ago by Alfredo Torre

The problem would come up when ser has only negative values or zeros. The function would replace all zeros { as MaxS(ser)*1.01 = 0 }. This is related to ticket 707... and InvChEx (StdLib) function.

comment:3 Changed 16 years ago by Víctor de Buen Remiro

Yes, its true.

There are other posible problems with discrete arithmetic.

  • If x is a big number could be x*1.01 == Inf
  • If x is an samll number could be x+1 == x

It would be better a random cycle

//Searches for a value that is no present in a time series
Real min = MinS(ser);
Real max = MaxS(ser);
Real x = Case(
  //If time series is constant we choice any other value
  min==max, If(min>=0, -1, +1),
  //If max value is lesser than maximum real we choice it
  max<TheMaxAbsValue, TheMaxAbsValue,
  //If min value is greater than minimum real we choice it
  min>TheMinAbsValue, TheMinAbsValue,
  //In other case we try a random value
  1==1, 
  {
    Real try = Rand(min,max);
    While(SumS(ser==ser*0+try), Real try := Rand(min,max) );
    try
  }
);

comment:4 Changed 16 years ago by Víctor de Buen Remiro

Milestone: Manteinance
Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.