def isclose(a, b, lim):
# is b close to a OR to aliquot of a in lim
if a == 0:
return abs(b - a) <= lim
else:
n = b/a
if b%a > a/2:
n += 1
c = a*n # closest aliquot to b
m = abs(b - c)
return m <= lim
...returns boolean.It's usable to test dispersion of sample around peaks.
Комментариев нет:
Отправить комментарий
Thanks for your posting!