понедельник, 15 октября 2012 г.

Does sample is located around periodic peak?

Next pseudo-code (Python) function tests does sample is located in domain around periodic peak:
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!