Is a single line of algorithm worth using a grid?
Well hello,
we're dealing with a little problem of statistics in my mathematics course by now. We call it the "Hanuta"-problem (Hanuta by the sweets company Ferrero). The question is, how to calculate all possibilities of getting the 36 different pictures of Hanuta by buying 60 Hanutas. And the probability of actually getting all 36 different at once.
We have an algorithm that calculates all ways to meet our goal, to have those 36 images at least once within 60 Hanutas.
T(n,m) = m*(T(n-1,m-1)+T(n-1,m)), while T(0,m) = 0 & T(n,1) = 1
And as I said: n = 60, m = 36
The problem is that n = 60, m = 10 is already too heavy for my own mac. (macbook pro)
We're now trying to approximate the exact value of n = 60 & m = 36, by comparing this function to graphs of T(10,m) {m,0,10} and T(20,m) {m,0,20}.
But actually the exact value would be helpful to solve our problem. But anyway even if I got time to use the grid for this calculation, in what form is this line of code supposed to be provided for use via XGrid?
I programmed this line in the Java IDE Eclipse. And the solutions of T(n,m) were entered into Excel to get a graph. But I can't use Java for distributed calculation, can I?
What actually matters is the single number for n = 60, m = 36. I just did the calculations e.g. n = 10, m = 0 to 10, for additional information on how these graphs look like.
Thorben



Stack overflow?
I am not sure I fully understand the problem, but if you're trying to compute T(n,m) recursively, you may need to increase the stack size to avoid stack overflow. This can be done using the command "ulimit -s" in the terminal. For example, "ulimit -s 16384" sets the stack size to 16 MB (default is 8 MB, I think).
Here's some simple Python code -- is this what you're trying to compute?
def T(n,m):
if n == 0:
return 0
elif m == 1:
return 1
else:
return m*(T(n-1,m-1)+T(n-1,m))
print T(60,36)
It is also possible not to use function recursion at all:
from cvxopt import matrix
T = matrix(0.,(61,37))
T[1:,1] = 1.
for n in range(1,61):
for m in range(2,min(37,n+1)):
T[n,m] = m*(T[n-1,m-1] + T[n-1,m])
print T[60,36]
1.5197917579e+89
The code makes use of the the matrix object from the Python extension module CVXOPT, but the code should be more or less self explanatory. (Note that the output from Python's range function does not include the end of the interval.)
The answer T[60,36] is returned almost instantly on my computer, so if this is actually what you want to compute, then you don't need Xgrid.
-Martin