worte the random yield function