optim_thresh function

Find threshold that optimises a given metric