#! /usr/bin/env python from __future__ import print_function import openturns as ot ot.Log.Show(ot.Log.ALL) distribution = ot.Frechet(2.5, 2.0, -1.5) size = 10000 sample = distribution.getSample(size) factory = ot.FrechetFactory() print('Distribution =', repr(distribution)) result = factory.buildEstimator(sample) estimatedDistribution = result.getDistribution() print('Estimated distribution =', repr(estimatedDistribution)) parameterDistribution = result.getParameterDistribution() print('Parameter distribution =', parameterDistribution) defaultDistribution = factory.build() print('Default distribution =', defaultDistribution) fromParameterDistribution = factory.build(distribution.getParameter()) print('Distribution from parameters =', fromParameterDistribution) typedEstimatedDistribution = factory.buildAsFrechet(sample) print('Typed estimated distribution =', typedEstimatedDistribution) defaultTypedDistribution = factory.buildAsFrechet() print('Default typed distribution =', defaultTypedDistribution) typedFromParameterDistribution = factory.buildAsFrechet( distribution.getParameter()) print('Typed distribution from parameters=', typedFromParameterDistribution) # More involved test: the sample distribution does not fit the factory # The distributions used : myFrechet = ot.Frechet(1.0, 1.0, 0.0)
axes = view.getAxes() _ = axes[0].set_xlim(-20.0, 20.0) # %% # We compare different fitting strategies for this sample: # # - use the histogram from the data (red) # - the GEV fitted distribution (black) # - the pure Frechet fitted distribution (green) # - the pure Gumbel fitted distribution (blue) # - the pure WeibullMax fitted distribution (dashed orange) # graph = myDistribution.drawPDF() graph.add(ot.HistogramFactory().build(sample).drawPDF()) distFrechet = ot.FrechetFactory().buildAsFrechet(sample) graph.add(distFrechet.drawPDF()) distGumbel = ot.GumbelFactory().buildAsGumbel(sample) graph.add(distGumbel.drawPDF()) # We change the line style of the WeibullMax. distWeibullMax = ot.WeibullMaxFactory().buildAsWeibullMax(sample) curveWeibullMax = distWeibullMax.drawPDF().getDrawable(0) curveWeibullMax.setLineStyle("dashed") graph.add(curveWeibullMax) graph.setColors(["black", "red", "green", "blue", "orange"]) graph.setLegends([ "GEV fitting", "histogram",