added cpp version of stratified sampling