Quantcast
Viewing all articles
Browse latest Browse all 4

Answer by Jean A. for What's the equivalent of fitdist and histfit in Python?

I tried your dataset using Openturns library

x is the list given in you json file.

import openturns as otfrom openturns.viewer import Viewimport matplotlib.pyplot as plt# first format your list x as a sample of dimension 1sample = ot.Sample(x,1) # use the LogNormalFactory to build a Lognormal distribution according to your sampledistribution = ot.LogNormalFactory().build(sample)# draw the pdf of the obtained distributiongraph = distribution.drawPDF()graph.setLegends(["LogNormal"])View(graph)plt.show()

Image may be NSFW.
Clik here to view.
enter image description here

If you want the parameters of the distribution

print(distribution)>>> LogNormal(muLog = -16.5263, sigmaLog = 0.636928, gamma = 3.01106e-08)

You can build the histogram the same way by calling HistogramFactory, then you can add one graph to another:

graph2 = ot.HistogramFactory().build(sample).drawPDF()graph2.setColors(['blue'])graph2.setLegends(["Histogram"])graph2.add(graph)View(graph2)

and set the boundaries values if you want to zoom

axes = view.getAxes()_ = axes[0].set_xlim(-0.6e-07, 2.8e-07)plt.show()

Image may be NSFW.
Clik here to view.
enter image description here


Viewing all articles
Browse latest Browse all 4

Trending Articles