Discard values in a fermentation

When a nutrient solution is seeded with yeast, the yeast will grow and ferment sugar into alcohol and carbon dioxide. You are conducting a series of experiments to determine the rate of fermentation, r, and have measurements of the fermentation rate measured in gram/ liter┬Ěday for a large number of identical experiments. To get a precise estimate of the fermentation rate, you want to compute the average of all the measured rates; however, you notice that some of the measurements are clearly erroneous. You decide to exclude all invalid measurements, which you define as measurements that are outside the range l < r < u.

Write a program that computes and returns the mean fermentation rate, taking only the valid measurements into account.

**Example:** Let's imagine that you have the measures

17, 16.3, 19.7, 18.2, 1.1, 20.3, 28.7, 121.1

An the lower bound is 15 and the upper bound is 25. The final average rate will be: 18.3