def discretize_oversample_1D(model, x_range, factor=10):
 x = np.arange((x_range[0] - (0.5 * (1 - (1 / factor)))), (x_range[1] + (0.5 * (1 + (1 / factor)))), (1.0 / factor))
 values = model(x)
 values = np.reshape(values, ((x.size // factor), factor))
 return values.mean(axis=1)[:(-1)]

def discretize_oversample_1D ( model , x_range , factor = 10 ) : x = np . arange ( ( x_range [ 0 ] - ( 0.5 * ( 1 - ( 1 / factor ) ) ) ) , ( x_range [ 1 ] + ( 0.5 * ( 1 + ( 1 / factor ) ) ) ) , ( 1.0 / factor ) ) values = model ( x ) values = np . reshape ( values , ( ( x . size // factor ) , factor ) ) return values . mean ( axis = 1 ) [ : ( - 1 ) ]
discretize model by taking the average on an oversampled grid .