filter for random sampling of input