{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "%(_matnorm_doc_callparams_note)s"
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The covariance matrices specified by "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "rowcov",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "colcov",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " must be (symmetric) positive definite. If the samples in "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "X",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " are "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "m \\times n"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", then "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "rowcov",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " must be "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "m \\times m"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "colcov",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " must be "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "n \\times n"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "mean",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " must be the same shape as "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "X",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The probability density function for "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "matrix_normal",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is"
            }
          ]
        },
        {
          "__type": "Math",
          "__tag": 4058,
          "value": "f(X) = (2 \\pi)^{-\\frac{mn}{2}}|U|^{-\\frac{n}{2}} |V|^{-\\frac{m}{2}}\n       \\exp\\left( -\\frac{1}{2} \\mathrm{Tr}\\left[ U^{-1} (X-M) V^{-1}\n       (X-M)^T \\right] \\right),"
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "where "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "M"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is the mean, "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "U"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " the among-row covariance matrix, "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "V"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " the among-column covariance matrix."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "allow_singular",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " behaviour of the "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "multivariate_normal",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " distribution is not currently supported. Covariance matrices must be full rank."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "matrix_normal",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " distribution is closely related to the "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "multivariate_normal",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " distribution. Specifically, "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\mathrm{Vec}(X)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (the vector formed by concatenating the columns  of "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "X"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ") has a multivariate normal distribution with mean "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\mathrm{Vec}(M)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and covariance "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "V \\otimes U"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (where "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\otimes"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is the Kronecker product). Sampling and pdf evaluation are "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\mathcal{O}(m^3 + n^3 + m^2 n + m n^2)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for the matrix normal, but "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\mathcal{O}(m^3 n^3)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for the equivalent multivariate normal, making this equivalent form algorithmically inefficient."
            }
          ]
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "versionadded",
          "base_type": "neutral",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "versionadded 0.17.0"
                }
              ]
            }
          ]
        }
      ],
      "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": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "pdf(X, mean=None, rowcov=1, colcov=1)",
              "annotation": "",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Probability density function."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "logpdf(X, mean=None, rowcov=1, colcov=1)",
              "annotation": "",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Log of the probability density function."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "rvs(mean=None, rowcov=1, colcov=1, size=1, random_state=None)",
              "annotation": "",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Draw random samples."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "entropy(rowcol=1, colcov=1)",
              "annotation": "",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Differential entropy."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "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": "A matrix normal random variable."
            }
          ]
        }
      ],
      "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": "%(_matnorm_doc_default_callparams)s",
              "annotation": "",
              "desc": []
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "%(_doc_random_state)s",
              "annotation": "",
              "desc": []
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "mean",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " keyword specifies the mean. The "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "rowcov",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " keyword specifies the among-row covariance matrix. The 'colcov' keyword specifies the among-column covariance matrix."
            }
          ]
        }
      ],
      "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/_multivariate.py",
  "item_line": 1113,
  "item_type": "class",
  "aliases": [
    "scipy.stats._multivariate.matrix_normal_gen"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nfrom scipy.stats import matrix_normal\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "M = np.arange(6).reshape(3,2); M\nU = np.diag([1,2,3]); U\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "V = 0.3*np.identity(2); V\nX = M + 0.1; X\nmatrix_normal.pdf(X, mean=M, rowcov=U, colcov=V)\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.stats import multivariate_normal\nvectorised_X = X.T.flatten()\nequiv_mean = M.T.flatten()\nequiv_cov = np.kron(V,U)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "multivariate_normal.pdf(vectorised_X, mean=equiv_mean, cov=equiv_cov)\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nAlternatively, the object may be called (as a function) to fix the mean\nand covariance parameters, returning a \"frozen\" matrix normal\nrandom variable:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "rv = matrix_normal(mean=None, rowcov=1, colcov=1)\n",
        "execution_status": "success"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "seed",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "matrix_normal_gen"
  },
  "references": null,
  "qa": "scipy.stats._multivariate:matrix_normal_gen",
  "arbitrary": [],
  "local_refs": [
    "%(_doc_random_state)s",
    "%(_matnorm_doc_default_callparams)s",
    "colcov=1",
    "colcov=1)",
    "entropy(rowcol=1",
    "logpdf(X",
    "mean=None",
    "pdf(X",
    "random_state=None)",
    "rowcov=1",
    "rvs(mean=None",
    "size=1"
  ]
}