3 ms·
As a quick sanity check, Mathematica 13.2.1 Kernel for Linux ARM (64-bit) Copyright 1988-2023 Wolfram Research, Inc. In[1]:= DI = Distributed; In[2]:
by jasomill 3y ago
As a quick sanity check,
Mathematica 13.2.1 Kernel for Linux ARM (64-bit)
Copyright 1988-2023 Wolfram Research, Inc.
In[1]:= DI = Distributed;
In[2]:= EV = Expectation;
In[3]:= SS = Subscript;
In[4]:= UD = UniformDistribution;
In[5]:= f[1] :=
EV[x, DI[x, UD[{0, 1}]]]
In[6]:= f[n_Integer] :=
EV[x, DI[x, UD[{0, f[n - 1]}]]]
In[7]:= Block[{n = 42},
EV[Product[SS[x, k], {k, 1, n}],
Map[DI[SS[x, #], UD[{0, 1}]] &,
Range[1, n]]]
== Product[EV[x, DI[x, UD[{0, 1}]]], {k, 1, n}]
== f[n]]
Out[7]= True
where n = 42 ∈ ℕ is arbitrary.
Alas, Mathematica doesn't appear to support actual nested distributions of the form UD[{1,UD[{1,...}]}], so, e.g.,
f[2]
== EV[x_2,
DI[x_2,
UD[{0,
EV[x_1,
DI[x_1, UD[{0,1}]]]}]]]
== EV[x_2,
DI[x_2,
UD[{0,1/2}]
== 1/4
which is trivial.
- jasomill 3y ago(As is the expectation of a uniform distribution in the first place. From the PDF for the uniform distribution (1/(b - a) for x ∈ [a,b], zero elsewhere) and the definition of EV as the integral of the product of the identity map and the PDF over the reals, EV[x, DI[x, UD[{a,b}]]] == Integrate[x * Piecewise[{ {1/(b - a), a <= x <= b}, {0, x < a || x > b}}], {x, -∞, ∞}] == Integrate[x * 1/(b - a), {x, a, b}] == ((b^2/2) - (a^2/2)) / (b - a) == (a + b)/2 so for a = 0, == b/2 no matter how many nested integrals it takes to define the real number b.)