5
$\begingroup$

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?

$\endgroup$
2
  • 3
    $\begingroup$ I'd like to be proven wrong but I don't think that there is a general way in Mathematica to do what you want which is to recognize the distribution of a sum of an arbitrary integer (still symbolic rather than known) number independent (and maybe identically distributed) random variables. Part of the problem is that not all sums have "nice looking" or "easily computed" distributions. The result for 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$
    – JimB
    Commented May 8, 2017 at 1:05
  • $\begingroup$ To represent a tuple of i.i.d distributions, you have 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$ Commented Sep 28, 2023 at 7:37

2 Answers 2

1
$\begingroup$

Still no automatic way seems possible for a variety of reasons.

Sometimes using the characteristic function (or the moment generating function) will result in a recognizable distribution. Well, recognizable to you and maybe not to Mathematica.

Here is an example. A Cauchy random variable has characteristic function

cf = CharacteristicFunction[CauchyDistribution[a, b], t]
(* E^(I a t - b t Sign[t]) *)

To find the characteristic function of the sum of $n$ iid (independent and identically distributed Cauchy random variables with parameters $a$ and $b$ one raises cf to the power $n$:

cfn = Simplify[cf^n, Assumptions -> n \[Element] PositiveIntegers] // ExpandAll
(* E^(I a n t - b n t Sign[t]) *)

That is recognized (by you) as the characteristic function of a Cauchy random variable with parameters $a n$ and $b n$.

$\endgroup$
1
$\begingroup$

How about the following?

Table[iid[k, BernoulliDistribution[p]], {k, 1, 10}]

{BernoulliDistribution[p], BinomialDistribution[2, p], BinomialDistribution[3, p], BinomialDistribution[4, p], BinomialDistribution[5, p], BinomialDistribution[6, p], BinomialDistribution[7, p], BinomialDistribution[8, p], BinomialDistribution[9, p], BinomialDistribution[10, p]}

Then

FindSequenceFunction[Table[iid[k, BernoulliDistribution[p]][[1]], {k, 2, 10}], n] /. 
n -> n - 1

n

$\endgroup$
1
  • $\begingroup$ +1 I think this might be the only "semi-automatic" way to find the distribution of a sum when the sum follows a standard distribution. For the sum of gamma distributed random variables the general distribution of the sum of $n$ such random variables is found with dist = GammaDistribution[a, b]; Table[{n, TransformedDistribution[Sum[x[i], {i, n}], Table[x[i] \[Distributed] dist, {i, n}]]}, {n, 2, 5}] // TableForm and noticing a pattern in the parameters. $\endgroup$
    – JimB
    Commented Oct 29, 2023 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.