ranvar.segment

ranvar.segment, function

def pure ranvar.segment(
    start: date,
    end: date,
    step: number,
    horizon: number,
    date: date,
    quantity: number,
    censoredDemandDate?: date)  : ranvar

Converts time-series into ranvars by collecting observations over moving windows.

Example

table Items[id] = with
  [| as id, as Start, as End, as Step, as Horizon |]
  [| "A", date(2024,1,1), date(2024,1,6), 1, 3 |]

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

expect Orders.id = Orders.MyId

Items.R = ranvar.segment(
  start: Items.Start,
  end: Items.End,
  step: Items.Step,
  horizon: Items.Horizon,
  date: Orders.Date,
  quantity: Orders.Qty)

Items.Cdf = cdf(Items.R)
Items.PLe1 = valueAt(Items.Cdf, 1)
Items.PLe3 = valueAt(Items.Cdf, 3)
Items.PLe4 = valueAt(Items.Cdf, 4)

show table "Segment distribution" with
  id
  mean(Items.R) as "Mean"
  Items.PLe1 as "P<=1"
  Items.PLe3 as "P<=3"
  Items.PLe4 as "P<=4"

This outputs the following table:

id Mean P<=1 P<=3 P<=4
A 2.75 0.25 0.75 1

This function computes, for each item, the ranvar of the sum of event quantities over periods of horizon length, that are entirely between the first and last date for that item. For example, for a start date on Jan 1st, end date on Jan 7th, a horizon of 3 days, and a single event of quantity 5 on Jan 2nd, the observed periods are:

Thus, the resulting ranvar is 60% Q = 0, 40% Q = 5.

When using the censoredDemandDate: argument, the censored days are skipped, i.e., the ranvar is generated as if these days never existed. Using the previous example, if the 3rd of January is censored, the ranvar segment is applied as if the 4th of January was the day following the 2nd of January.

Thus, the resulting ranvar is 50% Q = 0, 50% Q = 5.

See also

User Contributed Notes
0 notes + add a note