Fit a distribution using a non parametric approachΒΆ

In this example we are going to estimate a non parametrci distribution using the kernel smoothing method.

In [13]:
from __future__ import print_function
import openturns as ot
In [14]:
# Create data
distribution = ot.Gamma(6.0, 1.0)
sample = distribution.getSample(800)
In [15]:
# Estimate the Spearman correlation
kernel = ot.KernelSmoothing()
estimated = kernel.build(sample)

In [16]:
# Plot original distribution vs kernel smoothing
graph = ot.Graph()
graph.setTitle('Kernel smoothing vs original')
graph.add(distribution.drawPDF())
kernel_plot = estimated.drawPDF().getDrawable(0)
kernel_plot.setColor('blue')
graph.add(kernel_plot)
graph.setLegends(['original', 'KS'])
graph.setLegendPosition('topright')
graph
Out[16]:
../../_images/examples_statistical_estimation_estimate_non_parametric_distribution_5_0.svg