ranvars and zedfuncs
Ranvars represent probability distributions over $\mathbb{Z}$. Zedfuncs represent real-valued functions over
$\mathbb{Z}$. Ranvars are typically used for probabilistic forecasts, while zedfuncs represent economic outcomes over
integer decisions. Both types behave like generalized numbers: +, -, *, and ^ apply to them, with ranvar
operations interpreted as convolutions of independent random variables and zedfunc operations interpreted pointwise.
Arithmetic with numbers
When a number is combined with a ranvar, the number is promoted to a Dirac ranvar. When a number is combined with a zedfunc, the number is promoted to a constant zedfunc. Fractional numbers are rejected when promoted to Dirac ranvars.
r = poisson(5)
z = linear(2) - 2
show scalar "Ranvar plus number" with r + 3
show scalar "Zedfunc plus number" with z + 3
Decomposition
Ranvars can be decomposed into buckets with extend.ranvar, and recomposed with ranvar.buckets. Zedfuncs are queried
with valueAt. There is no bucket exposure for zedfuncs.
r = poisson(3)
table G = extend.ranvar(r)
G.P = int(r, G.Min, G.Max)
r2 = ranvar.buckets(G.P, G.Min, G.Max)
z = linear(1) * linear(1) - 4
v = valueAt(z, 3)
show summary "" with r, r2, v
Precision and accuracy
Ranvars and zedfuncs are compressed, approximate structures. Resolution decreases away from zero, and precision is limited to the most significant bits. Ranvar compression preserves local probability mass, while zedfunc compression preserves local variations.
Equivalent expressions can differ numerically. Keeping computations in plain numbers as long as possible improves accuracy and performance:
table T = with
[| as R |]
[| poisson(1) |]
[| poisson(3) |]
[| dirac(2) |]
a = sum(mean(T.R))
b = mean(sum(T.R))
show summary "" with a, b