.. 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_kolmogorov_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_kolmogorov_test.py: Use the Kolmogorov/Lilliefors test ================================== .. GENERATED FROM PYTHON SOURCE LINES 6-7 In this example we are going to perform a Kolmogorov or a Lilliefors goodness-of-fit test for a 1-d continuous distribution. .. GENERATED FROM PYTHON SOURCE LINES 9-12 .. code-block:: default import openturns as ot ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 13-14 Create the data. .. GENERATED FROM PYTHON SOURCE LINES 16-19 .. code-block:: default distribution = ot.Normal() sample = distribution.getSample(50) .. GENERATED FROM PYTHON SOURCE LINES 20-24 Case 1 : the distribution parameters are known. ----------------------------------------------- In the case where the parameters of the distribution are known, we must use the `Kolmogorov` static method and the distribution to be tested. .. GENERATED FROM PYTHON SOURCE LINES 26-30 .. code-block:: default result = ot.FittingTest.Kolmogorov(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.9861140480396968 .. GENERATED FROM PYTHON SOURCE LINES 31-32 Test succeeded ? .. GENERATED FROM PYTHON SOURCE LINES 34-36 .. code-block:: default result.getBinaryQualityMeasure() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 37-38 P-Value associated to the risk .. GENERATED FROM PYTHON SOURCE LINES 40-42 .. code-block:: default result.getPValue() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 0.9861140480396968 .. GENERATED FROM PYTHON SOURCE LINES 43-44 Threshold associated to the test. .. GENERATED FROM PYTHON SOURCE LINES 46-48 .. code-block:: default result.getThreshold() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 0.01 .. GENERATED FROM PYTHON SOURCE LINES 49-50 Observed value of the statistic. .. GENERATED FROM PYTHON SOURCE LINES 52-54 .. code-block:: default result.getStatistic() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 0.06127263683768702 .. GENERATED FROM PYTHON SOURCE LINES 55-59 Case 2 : the distribution parameters are estimated from the sample. ------------------------------------------------------------------- In the case where the parameters of the distribution are estimated from the sample, we must use the `Lilliefors` static method and the distribution factory to be tested. .. GENERATED FROM PYTHON SOURCE LINES 61-64 .. code-block:: default ot.ResourceMap.SetAsUnsignedInteger( "FittingTest-LillieforsMaximumSamplingSize", 1000) .. GENERATED FROM PYTHON SOURCE LINES 65-67 .. code-block:: default distributionFactory = ot.NormalFactory() .. GENERATED FROM PYTHON SOURCE LINES 68-72 .. code-block:: default dist, result = ot.FittingTest.Lilliefors(sample, distributionFactory, 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.983 .. GENERATED FROM PYTHON SOURCE LINES 73-75 .. code-block:: default dist .. raw:: html

Normal(mu = -0.0222592, sigma = 0.956433)



.. GENERATED FROM PYTHON SOURCE LINES 76-77 Test succeeded ? .. GENERATED FROM PYTHON SOURCE LINES 79-81 .. code-block:: default result.getBinaryQualityMeasure() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 82-83 P-Value associated to the risk .. GENERATED FROM PYTHON SOURCE LINES 85-87 .. code-block:: default result.getPValue() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 0.983 .. GENERATED FROM PYTHON SOURCE LINES 88-89 Threshold associated to the test. .. GENERATED FROM PYTHON SOURCE LINES 91-93 .. code-block:: default result.getThreshold() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 0.01 .. GENERATED FROM PYTHON SOURCE LINES 94-95 Observed value of the statistic. .. GENERATED FROM PYTHON SOURCE LINES 97-98 .. code-block:: default result.getStatistic() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 0.05110645729712043 .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.028 seconds) .. _sphx_glr_download_auto_data_analysis_statistical_tests_plot_kolmogorov_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_kolmogorov_test.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_kolmogorov_test.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_