Implement sampling-based crossfolding

This implements sampling-based crossfolding (#512).