2
$\begingroup$

In 13.3.1 on Windows 10 I find

cdf = CDF[ TransformedDistribution[\[Xi] + 
2*\[Mu], {\[Xi] \[Distributed] 
 DiscreteUniformDistribution[{0, n}], \[Mu] \[Distributed] 
 GeometricDistribution[p]}], t]

Piecewise[{{p, n > 0 && n - t < 0}, {p/(1 + n), (n == 0 && t >= 0) || (n > 0 && t == 0)}, {(p*(1 + Floor[t]))/(1 + n), n > 0 && t > 0 && n - t >= 0}}, 0]

and

cdf /. {n -> 5, p -> 1/2, t -> 7}

1/2

In order to verify it by the definition of the CDF,

n = 5; p = 1/2;
Probability[\[Xi] + 2*\[Mu] <= 7, {\[Xi] \[Distributed] 
DiscreteUniformDistribution[{0, n}], \[Mu] \[Distributed] 
GeometricDistribution[p]}]

41/48

At least one of the above results is not correct. The question is: what of these is correct? I think the latter.

$\endgroup$
5
  • $\begingroup$ Random experiment would suggest Probability is correct, and also CDF can be correct if you set n and p beforehand. But CDF is wrong if you compute it symbolically then do the replacement afterwards. With[{samp = 1000000}, Count[ RandomVariate[DiscreteUniformDistribution[{0, 5}], samp] + 2*RandomVariate[GeometricDistribution[1/2], samp] , x_ /; x <= 7]/samp ] // N You should report as a bug to Wolfram. It seems there are many such problems with TransformedDistribution. $\endgroup$
    – flinty
    Nov 16, 2023 at 20:03
  • $\begingroup$ @flinty: Thank you for your confirmation of the bug. BTW, Probability[\[Xi] + 2*\[Mu] <= t, {\[Xi] \[Distributed] DiscreteUniformDistribution[{0, n}], \[Mu] \[Distributed] GeometricDistribution[p]}] produces an answer in the terms of DifferenceRoots. I think that answer can be improved. $\endgroup$
    – user64494
    Nov 16, 2023 at 20:12
  • $\begingroup$ [CASE:5091726] has been submitted by me. $\endgroup$
    – user64494
    Nov 16, 2023 at 20:52
  • $\begingroup$ @flinty: Can you kindly present your [extended] comment as an answer, making use of PearsonChiSquareTest? It would also be useful for didactic purposes. $\endgroup$
    – user64494
    Nov 16, 2023 at 20:56
  • 1
    $\begingroup$ I don't have much confidence in Mathematica's symbolic distribution handling: for example With[{d = CauchyDistribution[0, 1]}, Expectation[(X - Y)^2, {X \[Distributed] d, Y \[Distributed] d}]] gives -2 but (X-Y)^2 cannot be negative. Of course, we should expect a positive infinity here, or undefined, but certainly not a negative number. It leads me to believe Mathematica is not handling the singularities in the underlying integrations properly. $\endgroup$
    – flinty
    Nov 21, 2023 at 23:03

1 Answer 1

7
$\begingroup$

The issue seems to be with DiscreteUniformDistribution when one of the parameters is an integer and the other an undefined variable. The following all give the correct answer:

CDF[TransformedDistribution[ξ + 2*μ, 
  {ξ \[Distributed] DiscreteUniformDistribution[{0, 5}],
   μ \[Distributed] GeometricDistribution[1/2]}], 7]
(* 41/48 *)

CDF[TransformedDistribution[ξ + 2*μ,
  {ξ \[Distributed] DiscreteUniformDistribution[{0, 5}],
   μ \[Distributed] GeometricDistribution[1/2]}], t] /. t -> 7
(* 41/48 *)

CDF[TransformedDistribution[ξ + 2*μ,
  {ξ \[Distributed] DiscreteUniformDistribution[{0, 5}]
   μ \[Distributed] GeometricDistribution[p]}], t] /. {t -> 7, p -> 1/2}
(* 41/48 *)

CDF[TransformedDistribution[ξ + 2*μ,
  {ξ \[Distributed] DiscreteUniformDistribution[{nmin, nmax}],
   μ \[Distributed] GeometricDistribution[p]}], t] /. {t -> 7, p -> 1/2, nmax -> 5, nmin -> 0}
(* 41/48 *)

The following all give the wrong answer:

CDF[TransformedDistribution[ξ + 2*μ, 
  {ξ \[Distributed] DiscreteUniformDistribution[{0, n}],
   μ \[Distributed] GeometricDistribution[p]}], t] /. {t -> 7, p -> 1/2, n -> 5}
(* 1/2 *)

CDF[TransformedDistribution[ξ + 2*μ,
  {ξ \[Distributed] DiscreteUniformDistribution[{nmin, 5}],
   μ \[Distributed] GeometricDistribution[p]}], t] /. {t -> 7, p -> 1/2, nmin -> 0}
(* 1/2 *)

CDF[TransformedDistribution[ξ + 2*μ, 
  {ξ \[Distributed] DiscreteUniformDistribution[{0, n}],
   μ \[Distributed] GeometricDistribution[p]},
  Assumptions -> n ∈ PositiveIntegers], t] /. {t -> 7, p -> 1/2, n -> 5}
(* 55/96 *)
$\endgroup$
3
  • $\begingroup$ Thank you for your work. It should be noticed that CDF[TransformedDistribution[\[Xi] + 2*\[Mu], {\[Xi] \[Distributed] DiscreteUniformDistribution[{nmin, nmax}], \[Mu] \[Distributed] GeometricDistribution[p]}], t] produced a complicated expression in terms of DifferenceRoots. Can it be simplified to a closed form expression? If so, I would accept your answer. $\endgroup$
    – user64494
    Nov 17, 2023 at 5:12
  • $\begingroup$ "closed form" is in the eye of the beholder. But applying //FunctionExpand gets rid of the DifferenceRoot. The resulting equation doesn't look nice but can be easily implemented in other languages (R, Excel, etc.). $\endgroup$
    – JimB
    Nov 17, 2023 at 6:10
  • $\begingroup$ Thank you. I accept it as a workaround. $\endgroup$
    – user64494
    Nov 17, 2023 at 6:29

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.