#707 closed defect (fixed)
InterpolaL (StdLib) works wrong for a Series with negative changes only
Reported by: | Alfredo Torre | Owned by: | Víctor de Buen Remiro |
---|---|---|---|
Priority: | highest | Milestone: | |
Component: | Various | Version: | 1.1.7 |
Severity: | blocker | Keywords: | InterpolaL, negative changes |
Cc: |
Description (last modified by )
InterpolaL (from StdLib) works wrong when the original Series only has negative changes and, at least, one no change. Please, see the next example:
Serie Ser.Qua = SubSer( 100*Pulse(y2009m01d01, Quarterly) + 90*Pulse(y2009m04d01, Quarterly) + 90*Pulse(y2009m07d01, Quarterly) + 80*Pulse(y2009m10d01, Quarterly), y2009m01d01, y2010m01d01); Serie Ser.Mon = InterpolaL(Ser.Qua, Monthly); The problem is in InvChEx function. I suggest this new code for InterpolaL: Serie InterpolaL(Serie ser, TimeSet dtn) { Serie dser = ((F-1):ser)>>CalInd(W,Dating(ser)); Serie iper = SubSer(CalVar(dtn,Dating(ser)),First(ser),Last(ser)); Serie inc = dser/iper; Serie dNser1 = InvCh(inc, Log(CalInd(W, dtn2))); Serie dNser2 = ExpandOmit(dNser1); Serie dNser = (B):dNser2; Date ini = Succ(First(dNser),dtn,-1); Serie sIniP = FirstS(ser)*CalInd(C,dtn); Serie sIni = SubSer(sIniP,ini,ini); SubSer(DifEq(1/(1-B),dNser,sIni),ini,Last(ser)) };
Attachments (1)
Change History (9)
comment:1 Changed 16 years ago by
Description: | modified (diff) |
---|
Changed 16 years ago by
Attachment: | interpolate.tol added |
---|
comment:2 Changed 16 years ago by
Status: | new → assigned |
---|
I dont't know who's the author of this function nor what is its target nor nothing about it.
I'm using my own interpolation attached functions.
Serie Ser.Qua = SubSer( 100*Pulse(y2009m01d01, Quarterly) + 90*Pulse(y2009m04d01, Quarterly) + 90*Pulse(y2009m07d01, Quarterly) + 80*Pulse(y2009m10d01, Quarterly), y2009m01d01, y2010m01d01); Serie Ser.Mon = InterpolaL(Ser.Qua, Monthly); //Linear interpolation Serie Ser.Mon_1 = InvChInterp(Ser.Qua, Monthly, "LinearSpline", 1); //Akima (smooth cubic) interpolation Serie Ser.Mon_3 = InvChInterp(Ser.Qua, Monthly, "AkimaSpline", 3);
If you want to test them I can to add them to StdLib.
comment:3 Changed 16 years ago by
That's great!
Just two more things to check if I've understood:
.- You suggest to create those functions in StdLib so they can be available in TOL. My doubt now is: aren't available now? Did you built them for this ticket?
.- Should InterpolaL be changed as
Serie InterpolaL(Serie ser, TimeSet dtn) { InvChInterp(ser, dtn, "LinearSpline", 1) };
?
comment:6 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:7 Changed 16 years ago by
Finally I've created a NameBlock StdLib::Interpolate for all interpolation related methods.
Serie Ser.Qua = SubSer( 100*Pulse(y2009m01d01, Quarterly) + 90*Pulse(y2009m04d01, Quarterly) + 90*Pulse(y2009m07d01, Quarterly) + 80*Pulse(y2009m10d01, Quarterly), y2009m01d01, y2010m01d01); Serie Ser.Mon = InterpolaL(Ser.Qua, Monthly); //Inverse dating change by means of linear interpolation Serie Ser.Mon_1 = Interpolate::Scalar::invCh(Ser.Qua, Monthly, "LinearSpline", 1); //Inverse dating change by means of Akima interpolation (smooth polynomial spline) Serie Ser.Mon_3 = Interpolate::Scalar::invCh(Ser.Qua, Monthly, "AkimaSpline", 3);
Interpolation functions