.. 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 :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_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-13 .. code-block:: Python import openturns as ot ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 14-15 Create the data. .. GENERATED FROM PYTHON SOURCE LINES 17-20 .. code-block:: Python distribution = ot.Normal() sample = distribution.getSample(50) .. GENERATED FROM PYTHON SOURCE LINES 21-26 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 28-31 .. code-block:: Python result = ot.FittingTest.Kolmogorov(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.9861140480396968 .. GENERATED FROM PYTHON SOURCE LINES 32-33 Test succeeded ? .. GENERATED FROM PYTHON SOURCE LINES 35-37 .. code-block:: Python result.getBinaryQualityMeasure() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 38-39 P-Value associated to the risk .. GENERATED FROM PYTHON SOURCE LINES 41-43 .. code-block:: Python result.getPValue() .. rst-class:: sphx-glr-script-out .. code-block:: none 0.9861140480396968 .. GENERATED FROM PYTHON SOURCE LINES 44-45 Threshold associated to the test. .. GENERATED FROM PYTHON SOURCE LINES 47-49 .. code-block:: Python result.getThreshold() .. rst-class:: sphx-glr-script-out .. code-block:: none 0.01 .. GENERATED FROM PYTHON SOURCE LINES 50-51 Observed value of the statistic. .. GENERATED FROM PYTHON SOURCE LINES 53-55 .. code-block:: Python result.getStatistic() .. rst-class:: sphx-glr-script-out .. code-block:: none 0.06127263683768702 .. GENERATED FROM PYTHON SOURCE LINES 56-61 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 63-65 .. code-block:: Python ot.ResourceMap.SetAsUnsignedInteger("FittingTest-LillieforsMaximumSamplingSize", 1000) .. GENERATED FROM PYTHON SOURCE LINES 66-68 .. code-block:: Python distributionFactory = ot.NormalFactory() .. GENERATED FROM PYTHON SOURCE LINES 69-72 .. code-block:: Python dist, result = ot.FittingTest.Lilliefors(sample, distributionFactory, 0.01) print("Conclusion=", result.getBinaryQualityMeasure(), "P-value=", result.getPValue()) .. rst-class:: sphx-glr-script-out .. code-block:: none Conclusion= True P-value= 0.983 .. GENERATED FROM PYTHON SOURCE LINES 73-75 .. code-block:: Python dist .. raw:: html
Normal


.. GENERATED FROM PYTHON SOURCE LINES 76-77 Test succeeded ? .. GENERATED FROM PYTHON SOURCE LINES 79-81 .. code-block:: Python result.getBinaryQualityMeasure() .. rst-class:: sphx-glr-script-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:: Python result.getPValue() .. rst-class:: sphx-glr-script-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:: Python result.getThreshold() .. rst-class:: sphx-glr-script-out .. code-block:: none 0.01 .. GENERATED FROM PYTHON SOURCE LINES 94-95 Observed value of the statistic. .. GENERATED FROM PYTHON SOURCE LINES 97-99 .. code-block:: Python result.getStatistic() .. rst-class:: sphx-glr-script-out .. code-block:: none 0.05110645729712043 .. GENERATED FROM PYTHON SOURCE LINES 100-101 Reset default settings .. GENERATED FROM PYTHON SOURCE LINES 101-102 .. code-block:: Python ot.ResourceMap.Reload() .. _sphx_glr_download_auto_data_analysis_statistical_tests_plot_kolmogorov_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_kolmogorov_test.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_kolmogorov_test.py `