Average value over a closed interval