I need to compute a ratio of two number that are computed in a cycle.
The problem is that b
becomes too big and it is equal to numpy.inf
at some point.
However, the ratio a/b should exist and not be zero.
for i in range(num_iter):
a += x[i]
b += y[i]
return a/b
What are tricks to compute this type of limits?
Please let me know if it is a wrong stackexchange site for the question.
Update:
The loop is finite, I have two arrays x
and y
that can be analysed in advance on big number or something.
I guess dividing x
and y
by some large number (rescaling) might work?