Test normality using Anderson-DarlingΒΆ

In this example we are going to evaluate whether a sample follows a normal distribution.

from __future__ import print_function
import openturns as ot
import openturns.viewer as viewer
from matplotlib import pylab as plt
ot.Log.Show(ot.Log.NONE)

Generate a sample

sample = ot.Normal().getSample(200)

Test normality

test_result = ot.NormalityTest.AndersonDarlingNormal(sample)
print('Component is normal?', test_result.getBinaryQualityMeasure(),
      'p-value=%.6g' % test_result.getPValue(),
      'threshold=%.6g' % test_result.getThreshold())

Out:

Component is normal? True p-value=0.382536 threshold=0.05

Test succeeded ?

test_result.getBinaryQualityMeasure()

Out:

True

P-Value

test_result.getPValue()

Out:

0.38253643373582846

Total running time of the script: ( 0 minutes 0.002 seconds)

Gallery generated by Sphinx-Gallery