Solved by KFrank in post #2 
              
              
                Hi Max! 

Yes, you can do this with pytorch tensor operations.  Use cumsum() 
divided by something like arange() to get the running mean.  Then 
test that against your sorted tensor to find when your condition first 
holds. 
Here is a pytorch version 0.3.0 script: 
import torch
torch.__version__

to…