I have read, that using Compile
command can speed up evaluations in mathematica. I have a mathematical expression, which I evaluate using following command:
n = 5000
k = 10
c = n/k
a = Floor[n* Log[2]]
b = a + 1
pk1 = Table[
Sum[Binomial[a, i]*StirlingS2[i, r]*(n - c)^(-i), {i, r, a}], {r,
1, c - 1}];
I was trying to use Compile
to evaluate this, but I don't know how to 'tell' Compile that I want to evaluate for range {r,1,c-1}
, I just made:
cf = Compile[{?},
Sum[Binomial[a, i]*StirlingS2[i, r]*(n - c)^(-i), {i, r, a}]]
Can someone suggest how I should transmor my comment to compile
commend? Or how I can speed up my evaluations in different way?
Binomial
andStirlingS2
cannot be compiled, so you are unlikely to benefit from compilation. $\endgroup$ParallelTable
may speed up a bit. As well as puttingn=5000.
and notn=5000
$\endgroup$