Difference between revisions of "StepInterp"

Line 10: Line 10:
 
= Notes =
 
= Notes =
  
StepInterp uses a "left-step" -- the step up takes place at the left side of each interval.  Sometimes you might want a "right-step", using the previous value smaller than or equal to X, rather than the next value greater than or equal to X.  One implementation of this other variant is a [[User-Defined Functions|UDF]]:
+
StepInterp uses "right-lookup", finding a value u in D such that x<=u.  In the interpolated graph, this makes the the step up takes place at the left edge of each interval.  Sometimes you might want a "left-lookup", finding a value u in D such that u<=x.  One implementation of this other variant is a [[User-Defined Functions|UDF]]:
  
  Function RStepInterp(D:ascending[I] ; R:Array[I] ; X ; I : Index )
+
  Function LStepInterp(D:ascending[I] ; R:Array[I] ; X ; I : Index )
 
  Definition:  
 
  Definition:  
 
     Var pos := StepInterp(D,@I,X,I);
 
     Var pos := StepInterp(D,@I,X,I);

Revision as of 20:34, 5 October 2007


(stub)

Declaration

StepInterp( D,A,X,I)

Notes

StepInterp uses "right-lookup", finding a value u in D such that x<=u. In the interpolated graph, this makes the the step up takes place at the left edge of each interval. Sometimes you might want a "left-lookup", finding a value u in D such that u<=x. One implementation of this other variant is a UDF:

Function LStepInterp(D:ascending[I] ; R:Array[I] ; X ; I : Index )
Definition: 
   Var pos := StepInterp(D,@I,X,I);
   R[@I= if X=D[@I=pos] then pos else max([1,pos-1]) ]

See Also

Comments


You are not allowed to post comments.