def triangle_density(x, mode):
    """Symetric triangle density with given mode and support of 2*mode
    
    Note: not normalized, max=1 at x=mode
    
    Parameters
    ----------
    x
    mode : float in [0, 0.5]
        mode of the density (argmax)
        
    Returns
    -------
    density on x : float
    
    """
    if 0 <= x <= mode:
        return x / mode
    elif mode < x <= 2 * mode:
        return 2 - x / mode
    else:
        return 0