def low_dim_sim_dist(x, a, b, squared=False):
    """
    Smooth function from distances to low-dimensional simiarlity. Compatible with numba.njit
    :param x: np.array pairwise distances
    :param a: float shape parameter a
    :param b: float shape parameter b
    :param squared: bool whether input distances are already squared
    :return: np.array low-dimensional similarities
    """
    if not squared:
        return 1.0 / (1.0 + a * x ** (2.0 * b))
    return 1.0 / (1.0 + a * x ** b)