Sure, I'll add some comments. As a disclaimer, this is pretty hacky right now. I'm separate the original trajectory into buckets for each of the k states, then in for-loop over ```n_samples```, I pick the closest frame to the current sample in feature space, and glue it to the trajectory.