Can I create a TransformedDistribution
that uses $k$ independent identically distributed (i.i.d.) random variables where $k$ is not fixed?
This question is closely related to TransformedDistribution using $k$ iid random variables.
The answer https://mathematica.stackexchange.com/a/65769/34820 states how the TransformedDistribution
can be derived for an arbitrary, but fixed $k$:
iid[k_, dist_] := TransformedDistribution[
Sum[a[i], {i, k}],
Table[Distributed[a[i], dist], {i, k}]
]
My question is whether I can also derive a general result for $k$ being any natural number.
To put a toy example: Let's take the sum of $k$ Bernoulli distributed variables with success probability $p$. This sum would be distributed according to a BinomialDistribution[k,p]
. Using the code from above, I can get:
In[1]:= iid[5, BernoulliDistribution[p]]
Out[2]= BinomialDistribution[5, p]
But if I try a general $k$, I get an error (as expected):
In[2]:= iid[k, BernoulliDistribution[p]]
During evaluation of In[2]:= Table::iterb: Iterator {i,k} does not have appropriate bounds.
I tried
Assuming[N \[Element] Integers && N > 0, iid[k, BernoulliDistribution[p]]]
but this gave the same error. Is there a way to get the general result BinomialDistribution[k,p]
using Mathematica?
Bernoulli[p]
you already know so just use that known result. For distributions that you don't know maybe using characteristic functions might give insight as to the resulting distribution. $\endgroup$ProductDistribution
. E.g.RandomVariate @ ProductDistribution[{BernoulliDistribution[1/2], 5}]
. I'm not sure to what extend this can be used for symbolic computations though. $\endgroup$