{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "versionadded",
          "base_type": "neutral",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "versionadded 1.6.0"
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The p-value relies on the approximation given by equation 1.8 in "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". It is important to keep in mind that the p-value is only accurate if one tests a simple hypothesis, i.e. the parameters of the reference distribution are known. If the parameters are estimated from the data (composite hypothesis), the computed p-value is not reliable."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Beginning in SciPy 1.9, "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "np.matrix"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " inputs (not recommended for new code) are converted to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "np.ndarray"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " before the calculation is performed. In this case, the output will be a scalar or "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "np.ndarray"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " of appropriate shape rather than a 2D "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "np.matrix"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". Similarly, while masked elements of masked arrays are ignored, the output will be a scalar or "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "np.ndarray"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " rather than a masked array with "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "mask=False"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Strong",
              "__tag": 4048,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Array API Standard Support"
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "cramervonmises",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._hypotests:cramervonmises"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "SCIPY_ARRAY_API=1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "====================  ====================  ====================\nLibrary               CPU                   GPU\n====================  ====================  ====================\nNumPy                 ✅                     n/a                 \nCuPy                  n/a                   ⛔                   \nPyTorch               ✅                     ⛔                   \nJAX                   ⚠️ no JIT             ⛔                   \nDask                  ⛔                     n/a                 \n====================  ====================  ====================",
          "execution_status": null
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "See "
                },
                {
                  "__type": "InlineRole",
                  "__tag": 4003,
                  "value": "dev-arrayapi",
                  "domain": null,
                  "role": "ref",
                  "inventory": null
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " for more information."
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "res",
              "annotation": "object with attributes",
              "desc": [
                {
                  "__type": "DefList",
                  "__tag": 4033,
                  "children": [
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "statistic"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "statistic"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "pvalue"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "pvalue"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Perform the one-sample Cramér-von Mises test for goodness of fit."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "rvs",
              "annotation": "array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "A 1-D array of observed values of the random variables "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "X_i"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". The sample must contain at least two observations."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "cdf",
              "annotation": "str or callable",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The cumulative distribution function "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "F"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " to test the observations against. If a string, it should be the name of a distribution in "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "scipy.stats",
                      "reference": {
                        "__type": "LocalRef",
                        "__tag": 4022,
                        "kind": "module",
                        "path": "scipy.stats"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". If a callable, that callable is used to calculate the cdf: "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "cdf(x, *args) -> float"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "args",
              "annotation": "tuple, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Distribution parameters. These are assumed to be known; see Notes."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "axis",
              "annotation": "int or None, default: 0",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If an int, the axis of the input along which to compute the statistic. The statistic of each axis-slice (e.g. row) of the input will appear in a corresponding element of the output. If "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "None"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", the input will be raveled before computing the statistic."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "nan_policy",
              "annotation": "{'propagate', 'omit', 'raise'}",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Defines how to handle input NaNs."
                    }
                  ]
                },
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "propagate"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ": if a NaN is present in the axis slice (e.g. row) along   which the  statistic is computed, the corresponding entry of the output   will be NaN."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "omit"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ": NaNs will be omitted when performing the calculation.   If insufficient data remains in the axis slice along which the   statistic is computed, the corresponding entry of the output will be   NaN."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "raise"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ": if a NaN is present, a "
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "ValueError"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " will be raised."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "keepdims",
              "annotation": "bool, default: False",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This performs a test of the goodness of fit of a cumulative distribution function (cdf) "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "F"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " compared to the empirical distribution function "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "F_n"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " of observed random variates "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "X_1, ..., X_n"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " that are assumed to be independent and identically distributed ("
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "). The null hypothesis is that the "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "X_i"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " have cumulative distribution "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "F"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The test statistic "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "T"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is defined as in "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", where "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\omega^2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is the Cramér-von Mises criterion and "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "x_i"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " are the observed values."
            }
          ]
        },
        {
          "__type": "Math",
          "__tag": 4058,
          "value": "T = n\\omega^2 =\n\\frac{1}{12n} + \\sum_{i=1}^n \\left[ \\frac{2i-1}{2n} - F(x_i) \\right]^2"
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "/scipy/stats/_hypotests.py",
  "item_line": 532,
  "item_type": "function",
  "aliases": [
    "scipy.stats.cramervonmises"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "Suppose we wish to test whether data generated by ``scipy.stats.norm.rvs``\nwere, in fact, drawn from the standard normal distribution. We choose a\nsignificance level of ``alpha=0.05``.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nfrom scipy import stats\nrng = np.random.default_rng(165417232101553420507139617764912913465)\nx = stats.norm.rvs(size=500, random_state=rng)\nres = stats.cramervonmises(x, 'norm')\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "res.statistic, res.pvalue\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThe p-value exceeds our chosen significance level, so we do not\nreject the null hypothesis that the observed sample is drawn from the\nstandard normal distribution.\n\nNow suppose we wish to check whether the same samples shifted by 2.1 is\nconsistent with being drawn from a normal distribution with a mean of 2.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "y = x + 2.1\nres = stats.cramervonmises(y, 'norm', args=(2,))\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "res.statistic, res.pvalue\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nHere we have used the `args` keyword to specify the mean (``loc``)\nof the normal distribution to test the data against. This is equivalent\nto the following, in which we create a frozen normal distribution with\nmean 2.1, then pass its ``cdf`` method as an argument.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "frozen_dist = stats.norm(loc=2)\nres = stats.cramervonmises(y, frozen_dist.cdf)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "res.statistic, res.pvalue\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nIn either case, we would reject the null hypothesis that the observed\nsample is drawn from a normal distribution with a mean of 2 (and default\nvariance of 1) because the p-value is less than our chosen\nsignificance level."
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "cramervonmises_2samp",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.stats._hypotests:cramervonmises_2samp"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": "func"
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "kstest",
        "reference": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "current-module",
          "version": "current-version",
          "kind": "to-resolve",
          "path": "kstest"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": "func"
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "rvs",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "cdf",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "args",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "()"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "axis",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "0"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "nan_policy",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "propagate"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "keepdims",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "False"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "cramervonmises"
  },
  "references": [
    ".. [1] Cramér-von Mises criterion, Wikipedia,",
    "       https://en.wikipedia.org/wiki/Cram%C3%A9r%E2%80%93von_Mises_criterion",
    ".. [2] Csörgő, S. and Faraway, J. (1996). The Exact and Asymptotic",
    "       Distribution of Cramér-von Mises Statistics. Journal of the",
    "       Royal Statistical Society, pp. 221-234."
  ],
  "qa": "scipy.stats._hypotests:cramervonmises",
  "arbitrary": [],
  "local_refs": [
    "args",
    "axis",
    "cdf",
    "keepdims",
    "nan_policy",
    "res",
    "rvs"
  ]
}