{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Let the covariance matrix be "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "A"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "L"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " be the lower Cholesky factor such that "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "L L^T = A"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". Whitening of a data point "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "x"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is performed by computing "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "L^{-1} x"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\log\\det{A}"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is calculated as "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "2tr(\\log{L})"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", where the "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\log"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " operation is performed element-wise."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "Covariance",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._covariance:Covariance"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " class does not support singular covariance matrices because the Cholesky decomposition does not exist for a singular covariance matrix."
            }
          ]
        }
      ],
      "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": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Representation of a covariance provided via the (lower) Cholesky factor"
            }
          ]
        }
      ],
      "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": "cholesky",
              "annotation": "array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The lower triangular Cholesky factor of the covariance matrix."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "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/_covariance.py",
  "item_line": 194,
  "item_type": "staticmethod",
  "aliases": [
    "scipy.stats.Covariance.from_cholesky"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "Prepare a symmetric positive definite covariance matrix ``A`` and a\ndata point ``x``.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nfrom scipy import stats\nrng = np.random.default_rng()\nn = 5\nA = rng.random(size=(n, n))\nA = A @ A.T  # make the covariance symmetric positive definite\nx = rng.random(size=n)\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nPerform the Cholesky decomposition of ``A`` and create the\n`Covariance` object.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "L = np.linalg.cholesky(A)\ncov = stats.Covariance.from_cholesky(L)\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nCompare the functionality of the `Covariance` object against\nreference implementation.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.linalg import solve_triangular\nres = cov.whiten(x)\nref = solve_triangular(L, x, lower=True)\nnp.allclose(res, ref)\nres = cov.log_pdet\nref = np.linalg.slogdet(A)[-1]\nnp.allclose(res, ref)\n",
        "execution_status": "success"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "cholesky",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "from_cholesky"
  },
  "references": null,
  "qa": "scipy.stats._covariance:Covariance.from_cholesky",
  "arbitrary": [],
  "local_refs": [
    "cholesky"
  ]
}