f(0.5) should be 0.11111111111... right? and I think you need to cast it to float array in HistogramPDF constructor or else you get integer division instead of float division. Look at np.astype. http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.astype.html.