replaced sample_discrete np.rand call with c stdlib