# MMA gives error when a different PDF expression is used for the same distribution

I have the following MMA code. Note that the function I declared at the very beginning is the PDF of square of a Nakagami Distributed random variable. With $m=1$ and $P=1$, $f(h)$ becomes Exponential Distribution with rate parameter 1, i.e., ExponentialDistribution

• Expectation expects a probability distribution but f[h] is not a probability distribution in the eyes of Expectation. Type 'Head[f] and the result will be Symbol rather than TransformedDistribution or some other type that is requred. – JimB Apr 26 '16 at 15:03
• @JimBaldwin, Thanks for your suggestion. Did you mean to put : h[Distributed] Head[f]? If yes, then I did it and the problem is still there... – Srestha Narayanan Apr 26 '16 at 15:28
• No. See extended comment below. – JimB Apr 26 '16 at 17:11

A PDF is not a distribution. To convert a PDF to its associated distribution use ProbabilityDistribution

Clear[λ, pb, Ps, μ]

f[h_] := 1/Gamma[m]*(m/P)^m*h^(m - 1)*Exp[-(m*h)/P];
m = 1; P = 1;

α = 4; δ = 2/α;

int = Assuming[{A > 0, r > 0, λ > 0},
Integrate[(1 - Exp[-x*h*r^(-1/δ)])*pb*λ*π, {r, A,
Infinity}, GenerateConditions -> False]]

(*  -pb π r λ - (pb π^(3/2) λ Erfc[r Sqrt[h μ]])/(
2 Sqrt[h μ])  *)

LI = Assuming[{A > 0, r > 0, λ > 0, x > 0},
Exp[-Expectation[int,
h \[Distributed] ProbabilityDistribution[f[h], {h, 0, Infinity}]]] //
FullSimplify]

(*  E^(pb π λ (r + ArcCot[r Sqrt[μ]]/Sqrt[μ]))  *)


Note that this is the same result obtained with h\[Distributed]ExponentialDistribution

LI === Assuming[{A > 0, r > 0, λ > 0, x > 0},
Exp[-Expectation[int, h \[Distributed] ExponentialDistribution]] //
FullSimplify]

(*  True  *)

x = s*Ps; A = r;
M = LI;

s = μ*r^α/Ps; B = M;

λ = 4; pb = 1/2; Ps = 19.9526; μ = 1.2589;

AverageProbSuccess[B_, λ_] :=
NIntegrate[B*2*π*λ*r*Exp[-π*λ*r^2], {r, 0, Infinity}]

AverageProbSuccess[B, λ]

(*  0.8346  *)


This is an extended comment. f[h] as defined while clearly a probability density function is not of the type of function that Expectation expects. Consider the difference between the two functions f and g below:

f[h_] := 1/Gamma[m]*(m/P)^m*h^(m - 1)*Exp[-(m*h)/P]

(* Symbol *)

(* PDF *)
f[h]
(* (E^(-((h m)/P)) h^(-1 + m) (m/P)^m)/Gamma[m] *)

(* Mean *)
Integrate[h f[h], {h, 0, ∞}]
(* ConditionalExpression[P, (Re[m] != 0 || m ∉ Reals) && 1 + Re[m] > 0 && Re[m/P] > 0]  *)


And now g

g := ProbabilityDistribution[1/Gamma[m]*(m/P)^m*h^(m - 1)*Exp[-(m*h)/P],
{h, 0, ∞},
Assumptions -> {m > 1, P > 0}]

`