ranvar.periodicr

ranvar.periodicr, function

def pure ranvar.periodicr(
  start: date,
  end: date,
  horizon: ranvar,
  date: date,
  quantity: number,
  censoredDemandDate: date): ranvar

Builds a ranvar by aggregating event quantities over moving windows whose length is drawn from horizon. Compared to ranvar.segment, it treats the series as periodic, so events near the edges are wrapped.

Example

table Items[id] = with
  [| as id, as Start, as End, as Lead |]
  [| "A", date(2024,1,1), date(2024,1,5), 2 |]

table Orders = with
  [| as MyId, as Date, as Qty |]
  [| "A", date(2024,1,1), 2 |]
  [| "A", date(2024,1,3), 1 |]

expect Orders.id = Orders.MyId

Items.R = ranvar.periodicr(
  start: Items.Start,
  end: Items.End,
  horizon: dirac(Items.Lead),
  date: Orders.Date,
  quantity: Orders.Qty)

show table "Periodic mean" with
  id
  mean(Items.R) as "Mean"

This outputs the following table:

id Mean
A 1.2

Remarks

When horizon is a dirac ranvar, the window size is fixed. The periodic behavior means windows that cross end wrap around to start.

See also

User Contributed Notes
0 notes + add a note