Sanhita Mallick wrote:

I am struggling with a simple recurring function

What is a recurring function? Do you mean looping?

Here is the script. T(i) are trees (as in graphs).
The program operates great, until the step where
norm_ted is calculated. Mysteriously norm_ted becomes
0, even though "mag" value is calculated correctly.
Also, strangely, sum_norm_ted also becomes zero.
What am I missing?

Do you mean for sum_norm_ted to be the sum over all i and j? If so, you should initialize it before the start of the outer loop.

I don't know why you are getting 0 at the end of the loop. It is as if sum_norm_ted and norm_ted are initialized but the inner loop doesn't run. Is this the exact code that you have trouble with?

Kent

Thanks.
-Sanhita

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
T = [F1, F2, F3]
k = len(T)
mean_ted = {}
for i in range(k): sum_norm_ted = 0.0
    mag = 0.0
    norm_ted = 0.0
    for j in range(k):
        if (i != j):
            ted= alg.ted(T[i], T[j])
            print 'TED ' + str(i) + str(j) + ' is ' +
str(ted)
            mag = 2 * (T[i].n + T[j].n) - 1
            print 'MAG ' + str(i) + str(j) + ' is ' +
str (mag) + ' and ' + str ( 2 * ted )
norm_ted = (2 * ted) / mag print 'norm_ted ' + str(i) + str(j) + ' is
' + str (norm_ted)
            sum_norm_ted = sum_norm_ted + norm_ted
            print 'sum_norm_ted ' + str(i) + str(j) +
' is ' + str (sum_norm_ted)
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor


_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to