I have this custom distribution that I want to use in Mathematica, but there appears to be some sort of problem I don't understand.
Also, when I compute the mean for the custom distribution via Mathematica, I get 2.74084, while the correct answer is 1.577661
Can someone help me? Thanks...
PvA[v_, A_] := (A^v*Exp[-A])/Factorial[v];
SumF[P_, i_, A_] := Sum[P[[vv + 1]]*PvA[i - vv + 1, A], {vv, 2, i}];
Pr[Aval_, k_] := Module[{A = Aval, P = Table[0, {k + 1}]},
P[[1]] = 1 - A;
P[[2]] = (1 - A)*(Exp[A] - 1);
For[i = 2, i <= k, i++,
P[[i + 1]] = (1/
PvA[0, A])*(P[[i]] - (P[[1]] + P[[2]])*PvA[i - 1, A] -
SumF[P, i - 1, A])];
Last[P]];
α = 0.5;
X = ProbabilityDistribution[((Pr[α, -1 + x]/
Sum[Pr[α, j], {j, 0, -1 + x}]) - (Pr[α, x]/
Sum[Pr[α, j], {j, 0, x}])), {x, 1, 30}]
Table::iterb: Iterator {x} does not have appropriate bounds.
Table::iterb: Iterator {x} does not have appropriate bounds.
Last::nolast: {} has zero length and no last element.
Table::iterb: Iterator {1+j} does not have appropriate bounds.
General::stop: Further output of Table::iterb will be suppressed during this calculation.
Last::nolast: {} has zero length and no last element.
Last::nolast: {} has zero length and no last element.
General::stop: Further output of Last::nolast will be suppressed during this calculation.
In[1893]:= N[Mean[X]]
Out[1893]= 2.74084
Sum[x*((Pr[α, -1 + x]/
Sum[Pr[α, j], {j, 0, -1 + x}]) - (Pr[α, x]/
Sum[Pr[α, j], {j, 0, x}])), {x, 1, 30}]
1.57661