def set_correlation_real(x1, x2, r):
    """
    Assign a correlation coefficient between ``x1`` and ``x2``

    Parameters
    ----------
    x1, x2 : UncertainReal
    r: float
    
    """
    if x1.is_elementary and x2.is_elementary:
        ln1 = x1._node
        ln2 = x2._node
        if not ln1.independent and not ln2.independent:
            if ln1 is ln2 and r != 1.0:
                raise ValueError("value should be 1.0, got: '{}'".format(r))
            else:
                ln1.correlation[ln2.uid] = r
                ln2.correlation[ln1.uid] = r
        else:
            raise RuntimeError('`set_correlation` called on independent node')
    else:
        raise TypeError(
            'Arguments must be elementary uncertain numbers,             got: {!r} and {!r}'
            .format(x1, x2))
