cdf

cdf, function

def pure cdf(d: ranvar): zedfunc

Returns, as a zedfunc, the cumulative distribution function of the ranvar d, defined as $k \mapsto \mathbb{P}[d \leq k]$.

Examples

d = poisson(3)
f = cdf(d)

show summary "CDF at k" with
  valueAt(f, 0) as "k=0"
  valueAt(f, 1) as "k=1"
  valueAt(f, 2) as "k=2"
  valueAt(f, 3) as "k=3"

Output:

k=0 k=1 k=2 k=3
0.04978787 0.1991515 0.4231969 0.6472424

Remarks

The survival function of a ranvar d can be obtained as 1 - cdf(d).

Recipes and best practices

Cumulative and marginal fill rates

In a supply chain context, the cdf function can be used to compute the cumulative fill rate of an item from its marginal fill rate (which is usually obtained with the fillrate function):

demand = negativeBinomial(5, 1)             // is a ranvar
marginalFillrate = fillrate(demand)         // is a ranvar
cumulativeFillrate = cdf(marginalFillrate)  // is a zedfunc

show scalar "Demand" with demand
show scalar "Marginal fill rate" with marginalFillrate
show scalar "Cumulative fill rate" with cumulativeFillrate

Output: three scalar tiles showing a ranvar and two zedfuncs.

Sell-through function

Also in a supply chain context, cdf can be used to compute the sell-through function, that is the function that maps each positive integer k to the probability of selling at least k units :


demand = negativeBinomial(5, 1)
sellThrough = 1 - cdf(demand + 1)

show scalar "Demand" with demand
show scalar "Sell-through function" with sellThrough

Output: two scalar tiles showing a ranvar and a zedfunc.

Computing probabilities

More generally, combined with valueAt, the cdf function can be used to compute the probablity of various events related to d (which can also be done with int, intLeft or intRight):

d = poisson(3)
f = cdf(d)

pLe4 = valueAt(f, 4)
pGt2 = valueAt(1 - f, 2)
pGe2 = valueAt(1 - f, 1)
pGt2Le4 = valueAt(f, 4) - valueAt(f, 2)
pGe2Le4 = valueAt(f, 4) - valueAt(f, 1)

show table "Probabilities" with
  pLe4 as "P[d <= 4]"
  pGt2 as "P[d > 2]"
  pGe2 as "P[d >= 2]"
  pGt2Le4 as "P[d > 2 and d <= 4]"
  pGe2Le4 as "P[d >= 2 and d <= 4]"

Output:

P[d <= 4] P[d > 2] P[d >= 2] P[d > 2 and d <= 4] P[d >= 2 and d <= 4]
0.8152764 0.5768031 0.8008484 0.3920795 0.6161249
User Contributed Notes
0 notes + add a note