f_2prior: makes sure that return value is within prior range (if lower or upper are present)