.. 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 :ref:`Go to the end ` 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-14 .. code-block:: Python import openturns as ot ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 15-16 Create data .. GENERATED FROM PYTHON SOURCE LINES 16-19 .. code-block:: Python distribution = ot.Poisson() sample = distribution.getSample(30) .. GENERATED FROM PYTHON SOURCE LINES 20-21 Fit a Poisson distribution .. GENERATED FROM PYTHON SOURCE LINES 21-23 .. code-block:: Python distribution = ot.PoissonFactory().build(sample) .. GENERATED FROM PYTHON SOURCE LINES 24-25 Test the fitted distribution .. GENERATED FROM PYTHON SOURCE LINES 25-27 .. code-block:: Python result = ot.FittingTest.ChiSquared(sample, distribution, 0.01) print("Conclusion=", result.getBinaryQualityMeasure(), "P-value=", result.getPValue()) .. rst-class:: sphx-glr-script-out .. code-block:: none Conclusion= True P-value= 0.3560857869884469 .. _sphx_glr_download_auto_data_analysis_statistical_tests_plot_chi2_fitting_test.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_chi2_fitting_test.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_chi2_fitting_test.py `