Don't go into infinite loop when sampling NaN elements.