Fit a curve to a histogram in Python

前端 未结 2 635
刺人心
刺人心 2020-12-25 10:20

I am trying to make to fit a curve to the values in a matplotlib generated histogram:

n, bins, patches = plt.hist(myData)

Where \"plt\" sta

2条回答
  •  难免孤独
    2020-12-25 10:59

    One way of doing it is to plot the PDF or the PMF of the curve with the same parameters as your histogram. For example, if you think you want to check how your histogram fits the normal distribution, you can plot the PDF of the Normal with the same mean & variance as your histogram. Create a random normal with the numpy.random.normal() function and plot its PDF. The way to do that is explained on the Numpy official page: https://numpy.org/doc/stable/reference/random/generated/numpy.random.normal.html

提交回复
热议问题