Function Repository Resource:

QuadraticFormDistribution

Source Notebook

Represent the distribution of a quadratic form with a multivariate normal

Contributed by: Wolfram Research

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.
ResourceFunction["QuadraticFormDistribution"] can be used with such functions as Mean and RandomReal.

Examples

Basic Examples (2) 

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 (2) 

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]=

The skewness and kurtosis of a quadratic form distribution:

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 (2) 

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]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 06 February 2019

License Information