5
$\begingroup$

In 13.3.1 on Windows 10 I execute

cdf = CDF[TransformedDistribution[\[Xi] + 
2*\[Mu], {\[Xi] \[Distributed] 
 BinomialDistribution[n, p], \[Mu] \[Distributed] 
 PoissonDistribution[\[Lambda]]}], t]

Piecewise[{{E^(-\[Lambda]), n > 0 && n - t < 0}, {(1 - p)^n/E^\[Lambda], (n == 0 && t >= 0) || (n > 0 && t == 0)}, {((1 - p)^(-1 - Floor[t])*((1 - p)^(1 + Floor[t]) - (1 - p)^n*p^(1 + Floor[t])*Binomial[n, 1 + Floor[t]]* Hypergeometric2F1[1, 1 - n + Floor[t], 2 + Floor[t], p/(-1 + p)]))/E^\[Lambda], n > 0 && t > 0 && n - t >= 0}}, 0]

cdf /. {n -> 5, p -> 1/3, \[Lambda] -> 1, t -> 10}

1/E

and, in order to check it by the definition of CDF,

Probability[\[Xi] + 2*\[Mu] <=  10, {\[Xi] \[Distributed] 
BinomialDistribution[n, p], \[Mu] \[Distributed] 
PoissonDistribution[\[Lambda]]}] /. {n -> 5, p -> 1/3, \[Lambda] -> 1}

27/(10 E)

The latter contradicts the former. I think the latter is true. Before submitting a possible bug to WTS, I'd like to discuss with other users how to obtain the correct expression for this CDF.

$\endgroup$
5
  • 1
    $\begingroup$ Same results on a MacOS 11.7.10, MMA version 13.3.0. $\endgroup$ Nov 1, 2023 at 8:31
  • $\begingroup$ @RomkeBontekoe: Thank you for your interest to the question and your work. $\endgroup$
    – user64494
    Nov 1, 2023 at 9:27
  • 1
    $\begingroup$ The former is definitely wrong, which can easily be checked by experiment: pastebin.com/mtZK1vFV $\endgroup$
    – flinty
    Nov 1, 2023 at 10:22
  • $\begingroup$ @flinty: Thank you. $\endgroup$
    – user64494
    Nov 1, 2023 at 11:39
  • $\begingroup$ My unsuccessful attempt is DiscreteConvolve[PDF[BinomialDistribution[n, p], t], PDF[TransformedDistribution[ 2*\[Mu], \[Mu] \[Distributed] PoissonDistribution[\[Lambda]]], t], t, x, Assumptions -> x <= n] and DiscreteConvolve[PDF[BinomialDistribution[n, p], t], PDF[TransformedDistribution[ 2*\[Mu], \[Mu] \[Distributed] PoissonDistribution[\[Lambda]]], t], t, x, Assumptions -> x > n]: both return the input. $\endgroup$
    – user64494
    Nov 1, 2023 at 12:25

2 Answers 2

4
$\begingroup$

I suspect that CDF is having trouble because t isn't restricted to non-negative integers and/or the specific values of the parameters need to be specified. The following works:

parms = {n -> 5, p -> 1/3, λ -> 1};
dist = TransformedDistribution[ξ + 2*μ, 
  {ξ \[Distributed]  BinomialDistribution[n, p], 
  μ \[Distributed] PoissonDistribution[λ]}] /. parms

Table[{t, CDF[dist /. parms, t],
   Probability[ξ + 2*μ <= t, 
    {ξ \[Distributed] BinomialDistribution[n, p], 
     μ \[Distributed] PoissonDistribution[λ]}] /. parms},
  {t, 0, 10}] // TableForm

Matching CDF values

Addition

Solving this with paper and pencil one finds the following:

pdf[t_, n_, p_, λ_] := Sum[Binomial[n, i] p^i (1 - p)^(n - i) Exp[-λ] λ^((t - i)/2)/((t - i)/2)!,
  {i, Boole[OddQ[t]], Min[t, n], 2}]; 
cdf[t_, n_, p_, λ_] := Sum[pdf[t0, n, p, λ], {t0, 0, t}]

Alternatively one can use probability generating functions.

(* Probability generating function of 2 X with X having a Poisson(λ) distribution *)
dist = TransformedDistribution[2 x, x \[Distributed] PoissonDistribution[λ]]
pgf2 = Expectation[z^(2 x), x \[Distributed] PoissonDistribution[λ]]
(* E^((-1 + z^2) λ) *)

(* Probability generating function of a binomial distribution *)
pgf1 = Expectation[z^x, x \[Distributed] BinomialDistribution[n, p]]
(* (1 + p (-1 + z))^n *)

(* PGF of the sum *)
pgf = pgf1 pgf2
(* E^((-1 + z^2) λ) (1 + p (-1 + z))^n *)

(* Now obtain the pdf for the sum *)
pdf2[t_, n_, p_, λ_] := (D[E^((-1 + z^2) λ) (1 + p (-1 + z))^n, {z, t}]/t!) /. z -> 0

When specifying $t$ and $n$ pdf is faster than pdf2. But when only t is specified pdf2 will produce a symbolic result and pdf won't.

$\endgroup$
8
  • $\begingroup$ Isn't it my Probability[\[Xi] + 2*\[Mu] <= 10, {\[Xi] \[Distributed] BinomialDistribution[n, p], \[Mu] \[Distributed] PoissonDistribution[\[Lambda]]}] /. {n -> 5, p -> 1/3, \[Lambda] -> 1} , only for the range of values instead of 10? $\endgroup$
    – user64494
    Nov 4, 2023 at 16:56
  • $\begingroup$ @user64494 I don't understand your question. $\endgroup$
    – JimB
    Nov 4, 2023 at 17:25
  • $\begingroup$ The correct expression for CDF[TransformedDistribution[\[Xi] + 2*\[Mu], {\[Xi] \[Distributed] BinomialDistribution[n, p], \[Mu] \[Distributed] PoissonDistribution[\[Lambda]]}], t] is asked. You present parms = {n -> 5, p -> 1/3, λ -> 1}; dist = TransformedDistribution[ξ + 2*μ, {ξ \[Distributed] BinomialDistribution[n, p], μ \[Distributed] PoissonDistribution[λ]}] /. parms.( The substituion /. parms is superfluous.). Hope you feel the difference. $\endgroup$
    – user64494
    Nov 4, 2023 at 17:35
  • $\begingroup$ Not feelin' it. It appears that the only currently "workable" (rather than "correct") expression has $t$ specified. One can get symbolic results but only for specific values of $t$. For example: cdf = CDF[TransformedDistribution[\[Xi] + 2*\[Mu], {\[Xi] \[Distributed] BinomialDistribution[n, p], \[Mu] \[Distributed] PoissonDistribution[\[Lambda]]}], 9] // FunctionExpand. $\endgroup$
    – JimB
    Nov 4, 2023 at 18:28
  • $\begingroup$ I more or less clearly see how to write down the correct expression for PDF[TransformedDistribution[\[Xi] + 2*\[Mu], {\[Xi] \[Distributed] BinomialDistribution[n, p], \[Mu] \[Distributed] PoissonDistribution[\[Lambda]]}], t] by hand. $\endgroup$
    – user64494
    Nov 4, 2023 at 18:40
1
$\begingroup$

    In[119]:= Clear[mgf]; 
    mgf[t_] := 
     MomentGeneratingFunction[
      dist = TransformedDistribution[
        x + 2*y, {x \[Distributed] BinomialDistribution[n, p], 
         y \[Distributed] PoissonDistribution[\[Lambda]]}], t]

For discrete distributions we have:

ZTransform[PDF[dist, x], x, Exp[-y]] == mgf[y]

ZTransform[PDF[dist, x], x, y] == mgf[-Log[y]]

PDF[dist, x] == InverseZTransform[mgf[-Log[y]], y, x]

In[121]:= resPDF = InverseZTransform[mgf[-Log[y]], y, x];

In[123]:= resCDF = Sum[InverseZTransform[mgf[-Log[y]], y, x], {x, 0, t}];

In[124]:= resCDF /. {n -> 5, p -> 1/3, \[Lambda] -> 1, t -> 10}

Out[124]= 27/(10 E)

I will file a bug, thank you for catching this.

$\endgroup$
2
  • $\begingroup$ If one uncovers resPDF and resCDF, then one sees the roots of some recurrent equation implicitly, not explicitly. This is not it. $\endgroup$
    – user64494
    Nov 4, 2023 at 16:53
  • $\begingroup$ Thank you for your report about the bug. I know several such bugs in CDF. $\endgroup$
    – user64494
    Nov 4, 2023 at 17:46

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.