function Y = Ehrenfest(d,X )

U=rand(1);
if (U<d/(d+1)) then
    V=rand(1);
    Y=X +(V>(X/d))-(V<(X/d));
    else Y=X;
end

endfunction