wrote sampling from cdf utility