{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "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": "",
              "annotation": "array",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "An array having shape (..., N, N) whose innermost two dimensions represent the covariance matrix of the variables."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Estimate a covariance matrix (or a stack of covariance matrices)."
            }
          ]
        }
      ],
      "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": "m",
              "annotation": "array",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "An array of shape "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "(..., N, M)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " whose innermost two dimensions contain "
                    },
                    {
                      "__type": "Emphasis",
                      "__tag": 4047,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "M"
                        }
                      ]
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " observations of "
                    },
                    {
                      "__type": "Emphasis",
                      "__tag": 4047,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "N"
                        }
                      ]
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " variables. That is, each row of "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "m"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " represents a variable, and each column a single observation of all those variables."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "xp",
              "annotation": "array_namespace, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The standard-compatible namespace for "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "m"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". Default: infer."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Covariance indicates the level to which two variables vary together. If we examine "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "N"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "-dimensional samples, "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "X = [x_1, x_2, ... x_N]^T"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", each with "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "M"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " observations, then element "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "C_{ij}"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " of the "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "N    imes N"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " covariance matrix is the covariance of "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "x_i"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "x_j"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". The element "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "C_{ii}"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is the variance of "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "x_i"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "With the exception of supporting batch input, this provides a subset of the functionality of "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy.cov"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "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/_lib/array_api_extra/_delegation.py",
  "item_line": 83,
  "item_type": "function",
  "aliases": [
    "scipy.differentiate.xpx.cov"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import array_api_strict as xp\nimport array_api_extra as xpx\n",
        "execution_status": "unexpected_exception"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nConsider two variables, :math:`x_0` and :math:`x_1`, which\ncorrelate perfectly, but in opposite directions:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "x = xp.asarray([[0, 2], [1, 1], [2, 0]]).T\nx\n",
        "execution_status": "unexpected_exception"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nNote how :math:`x_0` increases while :math:`x_1` decreases. The covariance\nmatrix shows this clearly:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "xpx.cov(x, xp=xp)\n",
        "execution_status": "unexpected_exception"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nNote that element :math:`C_{0,1}`, which shows the correlation between\n:math:`x_0` and :math:`x_1`, is negative.\n\nFurther, note how `x` and `y` are combined:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "x = xp.asarray([-2.1, -1,  4.3])\ny = xp.asarray([3,  1.1,  0.12])\nX = xp.stack((x, y), axis=0)\nxpx.cov(X, xp=xp)\n",
        "execution_status": "unexpected_exception"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "xpx.cov(x, xp=xp)\n",
        "execution_status": "unexpected_exception"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "xpx.cov(y, xp=xp)\n",
        "execution_status": "unexpected_exception"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nInput with more than two dimensions is treated as a stack of\ntwo-dimensional input.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "stack = xp.stack((X, 2*X))\nxpx.cov(stack)\n",
        "execution_status": "unexpected_exception"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n       [[ 46.84      , -17.144     ],\n        [-17.144     ,   8.57653333]]], dtype=array_api_strict.float64)"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "m",
        "annotation": "Array",
        "kind": "POSITIONAL_ONLY",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "xp",
        "annotation": "ModuleType | None",
        "kind": "KEYWORD_ONLY",
        "default": "None"
      }
    ],
    "return_annotation": "Array",
    "target_name": "cov"
  },
  "references": null,
  "qa": "scipy._lib.array_api_extra._delegation:cov",
  "arbitrary": [],
  "local_refs": [
    "m",
    "xp"
  ]
}