Skip to content

DOC: incorrect example for stats.cramervonmises #17999

@Yalikesifulei

Description

@Yalikesifulei

Issue with current documentation:

Documentation contains three examples of using cramervonmises, but all of them seem to have discrepancies between values of res.statistic, res.pvalue and descriptions below. For example, first one:

>>> import numpy as np
>>> from scipy import stats
>>> rng = np.random.default_rng()
>>> x = stats.norm.rvs(size=500, random_state=rng)
>>> res = stats.cramervonmises(x, 'norm')
>>> res.statistic, res.pvalue
(0.49121480855028343, 0.04189256516661377)

And the description is "The p-value 0.79 exceeds our chosen significance level, so we do not reject the null hypothesis that the observed sample is drawn from the standard normal distribution". Indeed, the null hypothesis shouldn't be rejected here as x clearly has standard normal distribution.
The same code on my laptop outputs far more different values, which are closer to what is described:

>>> res.statistic, res.pvalue
(0.10486572818633237, 0.561716331166968)

Two other examples share the same issue (see screenshot).

Idea or request for content:

Check and fix the numbers in code examples.

Additional context (e.g. screenshots, GIFs)

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues related to the SciPy documentation. Also check https://github.com/scipy/scipy.orgscipy.stats

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions