.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_data_analysis/statistical_tests/plot_chi2_fitting_test.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_data_analysis_statistical_tests_plot_chi2_fitting_test.py: Test a discrete distribution ============================ .. GENERATED FROM PYTHON SOURCE LINES 7-8 In this example we are going to perform a Chi2 goodness-of-fit test for an 1-d discrete distribution. .. GENERATED FROM PYTHON SOURCE LINES 10-15 .. code-block:: default import openturns as ot import openturns.viewer as viewer from matplotlib import pylab as plt ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 16-17 Create data .. GENERATED FROM PYTHON SOURCE LINES 17-20 .. code-block:: default distribution = ot.Poisson() sample = distribution.getSample(30) .. GENERATED FROM PYTHON SOURCE LINES 21-22 Fit a Poisson distribution .. GENERATED FROM PYTHON SOURCE LINES 22-24 .. code-block:: default distribution = ot.PoissonFactory().build(sample) .. GENERATED FROM PYTHON SOURCE LINES 25-26 Test the fitted distribution .. GENERATED FROM PYTHON SOURCE LINES 26-29 .. code-block:: default result = ot.FittingTest.ChiSquared(sample, distribution, 0.01) print('Conclusion=', result.getBinaryQualityMeasure(), 'P-value=', result.getPValue()) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Conclusion= True P-value= 0.7146093983625044 .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.002 seconds) .. _sphx_glr_download_auto_data_analysis_statistical_tests_plot_chi2_fitting_test.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_chi2_fitting_test.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_chi2_fitting_test.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_