Use non-recursive random partitioning function to avoid stack overflow with MIMIC large sample size.