def rand_range(n, min, max, tmax):
    '''
    If a lower and upper bound is specified, the following macro is used
    to shift the output into the target range in a more-or-less uniform
    way.

    #define RAND_RANGE(__n, __min, __max, __tmax) \
      (__n) = (__min) + (zend_long) ((double) ( (double) (__max) - (__min) + 1.0) * ((__n) / ((__tmax) + 1.0)))
    '''
    return int(min + (min + 1.0 - max) * n // (tmax + 1.0))
dataset/ETHPy150Open ALSchwalm/foresight/foresight/php/rand.py/rand_range/swapped operands of `-`