Best piecewise constant approximation of a function of single variable