Assuming $0<q<1$. I built these two functions
A[k_,q_]:=Sum[PDF[BinomialDistribution[i, q], k]*PDF[ZipfDistribution[n], i], {i, k, Infinity}]
and
B[k_,q_]:=Piecewise[{
{(1/Zeta[n + 1])*PolyLog[n + 1, 1 - q], k == 0},
{(1/(Zeta[n + 1]*k!))*(q/(1 - q))^k*Sum[CoefficientList[Product[x - j, {j, 1, k - 1}],x][[-i]]* PolyLog[n + i - k, 1 - q], {i, 1, k}], k > 0}}]
Functions A and B are mathematically equivalent for $k\geq1$. (Function B is faster than function A.)
When I compute $A[25,0.6]$ and $B[25,0.6]$ with $n=3$, I start to get a little difference between the results $(5.61124*10^{-7},5.61132*10^{-7})$. So, the question is, why is this difference? Does anyone know how to avoid this round-off problem?
B[25, 0.6]
give me:11.09
not:5.61124*10^-7
? $\endgroup$n 1
. $\endgroup$A[25, 6/10] == B[25, 6/10] // FullSimplify
andN[A[25, 6/10], 20]
. In general, see the many questions on this site about increasing precision of the various Mathematica functions, such asSum
$\endgroup$Sum
) sometimes have difficulty with inexact input (e.g.0.6
instead of6/10
). The number5.61124*10^-7
is the result forA[]
returned byNSum
. PossiblySum
failed and calledNSum
as a backup. $\endgroup$