matplotlib - Fitting Maxwell-Boltzman distribution in Python -


is possible make fit maxwell-boltzmann data in matplotlib or similar module in python?

scipy.stats has support maxwell distribution.


import scipy.stats stats import matplotlib.pyplot plt import numpy np  maxwell = stats.maxwell data = maxwell.rvs(loc=0, scale=5, size=10000)  params = maxwell.fit(data, floc=0) print(params) # (0, 4.9808603062591041)  plt.hist(data, bins=20, normed=true) x = np.linspace(0, 25, 100) plt.plot(x, maxwell.pdf(x, *params), lw=3) plt.show() 

enter image description here

the first parameter location or shift away zero. second parameter scaling parameter, denoted a on the wikipedia page.

to generate random variates (random data) distribution, use rvs method:

newdata = maxwell.rvs(*params, size=100) 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -