Distribution fitting test using Chi2ΒΆ

In this example we are going to perform a Chi2 goodness-of-fit test for an 1-d discrete distribution.

In [5]:
from __future__ import print_function
import openturns as ot
In [6]:
# Create data
distribution = ot.Poisson()
sample = distribution.getSample(30)
In [7]:
# Fit a Poisson distribution
distribution = ot.PoissonFactory().build(sample)
In [8]:
# Test the fitted distribution
result = ot.FittingTest.ChiSquared(sample, distribution, 0.99)
print('Conclusion=', result.getBinaryQualityMeasure(), 'P-value=', result.getPValue())
Conclusion= True P-value= 0.6585272444518727