Recreating the sum symbol using python I am currently reading a white paper relating to Expectation-Maximisation (EM) and would like to encode a formula so I can play with it in order to help my understanding. The formula in question is a sum over values and shown below;



I am wondering what the advice on the best way to acheive this would be. I am currently thinking about using a for loop to create some kind of cumulative value as I iterate from t = 1 to m.
In most cases, I would go for NumPy.
Implement a Python function f(t) that calculates the $t$-th summand.
Then run

import numpy as np
result = np.array([f(t) for t in range(1,m+1)]).sum()


This will be very fast, unless $m$ is so large that [f(t) for t in range(1,m+1)] does not fit into memory. In this case, I would follow your approach and use a for-loop:

result = 0
for t in range(1, m+1):
    result += f(t)