There may also be a possibility to generate ys for *all* samples at once. If they were uniformly distributed, you could create a n_samples x n_classes random matrix and do an argsort on each row, etc. I'm not sure how to do this once weighted.