関数Gaussian_multiDimension_multi マニュアル

(The documentation of function Gaussian_multiDimension_multi)

Last Update: 2021/12/1


◆機能・用途(Purpose)

多次元ガウス分布 \[\begin{equation} f(\posx) =\frac{1}{\sqrt{(2\pi)^D|\myvector{\Sigma}|}} \exp\left[ -\frac{1}{2}(\posx-\myvector{x_{ave}})^T \myvector{\Sigma}^{-1} (\posx-\myvector{x_{ave}}) \right] \label{eq.definition} \end{equation}\] の複数の\(\posx\)における値を一括で求める。 ここで\(D\)は次元、\(\posx\)は\(D\)次元ベクトル、 \(\myvector{x_{ave}}\)はガウス分布の平均値(\(D\)次元ベクトル)、 \(\myvector{\Sigma}\)はガウス分布の共分散行列(サイズ:\(D\times D\))である。
Compute the values of a multi-dimension Gaussian distribution (eq. \ref{eq.definition}) for multiple \(\posx\) values, where \(D\) is the dimension, \(\posx\) is a \(D\)-dimension vector, \(\myvector{x_{ave}}\) is an average of the Gaussian distribution which is also a \(D\)-dimension vector, and \(\myvector{\Sigma}\) is a covariance matrix of the Gaussian distribution which has a size of \(D\times D\).


◆形式(Format)

#include <gaussian.h>
inline double ∗Gaussian_multiDimension_multi
(const struct columnvector average,const struct matrix covariance,
  const int N,const struct columnvector ∗x)


◆引数(Arguments)

average ガウス分布の平均値ベクトル\(\myvector{x_{ave}}\)。
The average value vector \(\myvector{x_{ave}}\) of the Gaussian distribution.
covariance ガウス分布の共分散行列\(\myvector{\Sigma}\)。
The covariance matrix \(\myvector{\Sigma}\) of the Gaussian distribution.
N ガウス分布の値を求めたい変数値ベクトル\(\posx\)の個数。
The number of variable value vectors \(\posx\) for which the values of the Gaussian distribution are needed.
x ガウス分布の値を求めたい変数値ベクトル\(\posx\)を並べた配列。
An array composed of the variable value vectors \(\posx\) for which the values of the Gaussian distribution are needed.


◆戻り値(Return value)

(\ref{eq.definition})式に基づいて計算される\(f(\posx)\)の値を \(\posx=\)x[0],\(\cdots\),x[N-1]について並べた配列。
An array composed of the values of \(f(\posx)\) for \(\posx=\)x[0],\(\cdots\),x[N-1] calculated based on eq. (\ref{eq.definition}).


◆使用例(Example)

struct columnvector x[5];
struct columnvector average;
struct matrix covariance;
double ∗value=Gaussian_multiDimension_multi(average,covariance,5,x);


◆計算方法(Computation method)

関数LU_decomposition (matrix/inverse.h) を用いて\(\myvector{\Sigma}\)のLU分解を求める。 次にその結果を用いて 関数matrix_inverse_givenLU (matrix/inverse.h) により\(\myvector{\Sigma}^{-1}\)を、 関数matrix_determinant_givenLU (matrix/inverse.h) により\(|\myvector{\Sigma}|\)を求める。 これらを用いて(\ref{eq.definition})式により\(f(\posx)\)を計算する。
An LU decomposition of \(\myvector{\Sigma}\) is first computed by function LU_decomposition (matrix/inverse.h). Next, using the decomposition, \(\myvector{\Sigma}^{-1}\) and \(|\myvector{\Sigma}|\) are computed by functions matrix_inverse_givenLU and matrix_determinant_givenLU (both in matrix/inverse.h), respectively. Finally, using these quantities, \(f(\posx)\) is calculated by eq. (\ref{eq.definition}).

関数Gaussian_MultiDimensionとの違いは \(\myvector{\Sigma}^{-1}\)を求める点にある。 Gaussian_MultiDimensionの場合には 1つの\(\posx\)に対する\(f(\posx)\)だけを計算すれば良いので 逆行列を求めるよりも \(\myvector{\Sigma}^{-1}(\posx-\myvector{x_{ave}})\) を求める方が計算時間が短くて済む。 しかし\(\posx\)が多数ある場合、 \(\myvector{\Sigma}^{-1}(\posx-\myvector{x_{ave}})\) を求めようとすると連立方程式を何度も解かなければならなくなる。 \(\myvector{\Sigma}^{-1}\)を求めるには連立方程式を\(D\)回解けば良いので、 \(\posx\)の個数が\(D\)を上回る場合には \(\myvector{\Sigma}^{-1}\)を求める方が計算時間が短くなると期待される。
The algorithm of this function is characterized by calculating \(\myvector{\Sigma}^{-1}\), which is not computed in function Gaussian_MultiDimension. In case of the function Gaussian_MultiDimension, \(f(\posx)\) for only one \(\posx\) is needed. Thus the computation time is shorter to calculate \(\myvector{\Sigma}^{-1}(\posx-\myvector{x_{ave}})\) than to calculate \(\myvector{\Sigma}^{-1}\). When there are many \(\posx\), computation of \(\myvector{\Sigma}^{-1}(\posx-\myvector{x_{ave}})\) requires solving a simultaneous equation for many times. Note that the simultaneous equation needs to be solved for \(D\) times to compute \(\myvector{\Sigma}^{-1}\). Thus it is expected that solving for \(\myvector{\Sigma}^{-1}\) is faster than solving for \(\myvector{\Sigma}^{-1}(\posx-\myvector{x_{ave}})\) when the number of \(\posx\) is greater than \(D\).


◆検証(Validation)

この関数で求めた値が正しいことについては 関数Gaussian_multiDimensionと同じ検証によって確認した。
The values obtained by this function are validated by the same tests as those performed for function Gaussian_multiDimension.