test function: random sample