FittingTest_ChiSquared¶
- FittingTest_ChiSquared(*args)¶
Perform a goodness-of-fit test for 1-d discrete distributions.
Refer to Chi-squared goodness of fit test.
- Parameters
- sample2-d sequence of float
Tested sample.
- model
Distribution
orDistributionFactory
Tested distribution.
- levelfloat, , optional
This is the risk of committing a Type I error, that is an incorrect rejection of a true null hypothesis.
- n_parametersint, , optional
The number of parameters in the distribution that have been estimated from the sample. This parameter must not be provided if a
DistributionFactory
was provided as the second argument (it will internally be set to the number of parameters estimated by theDistributionFactory
). It can be specified if aDistribution
was provided as the second argument, but if it is not, it will be set equal to 0.
- Returns
- fitted_dist
Distribution
Estilmated distribution (if model is of type
DistributionFactory
).- test_result
TestResult
Test result.
- fitted_dist
- Raises
- TypeErrorIf the distribution is not discrete or if the sample is
multivariate.
Examples
>>> import openturns as ot >>> ot.RandomGenerator.SetSeed(0) >>> distribution = ot.Poisson() >>> sample = distribution.getSample(30) >>> fitted_dist, test_result = ot.FittingTest.ChiSquared(sample, ot.PoissonFactory(), 0.01) >>> test_result class=TestResult name=Unnamed type=ChiSquared Poisson binaryQualityMeasure=true p-value threshold=0.01 p-value=0.698061 statistic=0.150497 description=[Poisson(lambda = 1.06667) vs sample Poisson]