Replace matplotlib histogram calculation with numpy/scipy
Context
Currently, the codebase computes histogram information using the plotting library matplotlib, but does not use the histogram data for plotting.
However, it would be more prudent to use a specialized scientific data processing library to compute histogram bins.
We expect either numpy or scipy to be more efficient and suitable for such algorithms.
As an example, we can refer to: https://numpy.org/doc/stable/reference/generated/numpy.histogram.html
Objective
Replace matplotlib.pyplot.histwith numpy.histogram in instances where the histogram bins are used for numerical approximation and not plotting.
Edited by Daniel Tang