Wolfram Computation Meets Knowledge

QuadraticFormDistribution

Contributed by: Wolfram Research

Represents the distribution of a quadratic form with a multivariate normal

ResourceFunction["QuadraticFormDistribution"][{a,b,c},{μ,Σ}]

represents the distribution of a quadratic form z.a.z+b.z+c for multivariate normal z.

Details and Options

ResourceFunction["QuadraticFormDistribution"] is the distribution of z.a.z+b.z+c for real-valued p×p symmetric positive definite matrix a, length-p vector b, scalar c, and p-dimensional multivariate normal vector z.
QuadraticFormDistribution can be used with such functions as Mean and RandomReal.

Examples

Basic Examples

The mean of a quadratic form distribution:

In[1]:=
Mean[ResourceFunction[
  "QuadraticFormDistribution"][{{{Subscript[a, 11], Subscript[a, 12]}, {Subscript[a, 12], Subscript[a, 22]}}, {Subscript[b, 1], Subscript[b, 2]}, c}, {{Subscript[\[Mu], 1], Subscript[\[Mu], 2]}, {{Subscript[\[Sigma], 11]^2, \[Rho]*Subscript[\[Sigma], 11]*Subscript[\[Sigma], 22]}, {\[Rho]*Subscript[\[Sigma], 11]*Subscript[\[Sigma], 22], Subscript[\[Sigma], 22]^2}}}]]
Out[1]=

The variance of a quadratic form distribution:

In[2]:=
Variance[ResourceFunction[
  "QuadraticFormDistribution"][{{{1, 1/2}, {1/2, 1}}, {Subscript[b, 1], Subscript[b, 2]}, c}, {{Subscript[\[Mu], 1], Subscript[\[Mu], 2]}, {{1, 0}, {0, 1}}}]]
Out[2]=

Scope

Generate a set of pseudorandom numbers that follow a quadratic form distribution:

In[3]:=
RandomReal[
 ResourceFunction[
  "QuadraticFormDistribution"][{{{1, 1/2}, {1/2, 1}}, {1, 2}, 5}, {{0, 0}, {{1, 0}, {0, 1}}}], 10]
Out[3]=
In[4]:=
Skewness[ResourceFunction[
  "QuadraticFormDistribution"][{{{1, 1/2}, {1/2, 1}}, {Subscript[b, 1], Subscript[b, 2]}, c}, {{Subscript[\[Mu], 1], Subscript[\[Mu], 2]}, {{1, 0}, {0, 1}}}]]
Out[4]=
In[5]:=
Kurtosis[ResourceFunction[
  "QuadraticFormDistribution"][{{{1, 1/2}, {1/2, 1}}, {Subscript[b, 1], Subscript[b, 2]}, c}, {{Subscript[\[Mu], 1], Subscript[\[Mu], 2]}, {{1, 0}, {0, 1}}}]]
Out[5]=

Possible Issues

PDF and CDF can only be evaluated using Series:

In[6]:=
dist = ResourceFunction[
  "QuadraticFormDistribution"][{{{1, 0}, {0, 1}}, {1, 2}, 0}, {{0, 0}, {{1, 0}, {0, 1}}}]
Out[6]=
In[7]:=
pdf = PDF[dist, x]
Out[7]=
In[8]:=
Series[pdf, {x, -5/4, 2}]
Out[8]=
In[9]:=
Series[CDF[dist, x], {x, -5/4, 2}]
Out[9]=

Series expansion must be about the lower support point for the distribution:

In[10]:=
Series[CDF[dist, x], {x, 0, 2}]
Out[10]=

Substitution of invalid parameters into symbolic outputs gives results that are not meaningful:

In[11]:=
Mean[ResourceFunction[
   "QuadraticFormDistribution"][{{{1, 1/2}, {1/2, 1}}, {Subscript[b, 1], Subscript[b, 2]}, c}, {{0, 1}, {{1, 0}, {0, 1}}}]] /. {Subscript[b, 1] -> 1, Subscript[b, 2] -> I, c -> I}
Out[11]=

Resource History