random function from amb_kf.c implemented