37#ifndef STK_MULTILAW_NORMAL_H
38#define STK_MULTILAW_NORMAL_H
99template <
class RowVector>
109 :
Base(
_T(
"MultiLaw::Normal"))
118 inline RowVector
const&
mu()
const {
return mu_;}
129 if (
mu.range() !=
sigma.range())
145 int rank =
decomp_.rank(), end =
mu_.begin() + rank;
146 for (
int j=
mu_.begin();
j< end;
j++)
168 if (x.range() !=
mu_.range() )
171 return std::exp((
double)
lpdf(x));
182 if (x.range() !=
mu_.range() )
187 + 0.5 * log((
double)
decomp_.det());
196 template <
class Array>
200 if (data.cols() !=
mu_.range() )
203 const int first = data.beginRows(),
last = data.lastIdxRows();
205 for (
int i=first;
i<=
last;
i++)
212 + 0.5 * log((
double)
decomp_.det())
221 virtual void rand( RowVector& x)
const
233 template <
class Array>
In this file, we define Array2DDiagonal class.
In this file we define the Array2DLowerTriangular class.
In this file, we define Array2DSquare class.
In this file we define the ArrayXXTriangular class.
In this file, we define the final class Array2D.
In this file we implement the functors for performing operations on Array2D arrays.
In this file we implement the final class CArrayPoint.
In this file we implement the final class CArraySquare.
In this file we implement the final class CArrayVector.
In this file we implement the final class CArray.
In this file we define the constant Arrays.
In this file we give the main mathematical constants.
In this file we define the Normal probability law class.
#define STKRUNTIME_ERROR_NO_ARG(Where, Error)
In this file we define the Interface base classes IMultiLaw and JointProbability.
In this file we define the SymEigen class (for a symmetric matrix).
#define _T(x)
Let x unmodified.
Define the constant point.
Derived & resize(Range const &I, Range const &J)
resize the array.
virtual bool run()
run the computations.
String const & error() const
get the last error message.
virtual void setData(YArray_ const &y, XArray_ const &x)
set the data set.
Interface base Class for the multivariate distributions.
Class for the multivariate Normal distribution.
MultiLaw::IMultiLaw< RowVector > Base
ArraySquareX const & sigma() const
@return the variance-covariance matrix
ArrayDiagonalX invEigenvalues_
inverse of the eigenvalues of sigma_
SymEigen< ArraySquareX > decomp_
the decomposition in eigenvalues of the covariance matrix
RowVector mu_
The position parameter.
virtual Real pdf(RowVector const &x) const
compute the probability distribution function (density) of the multivariate normal law
SymEigen< ArraySquareX > const & decomp() const
@return the eigenvalue decomposition
virtual ~Normal()
destructor.
void rand(ArrayBase< Array > &x) const
simulate a realization of the Multivariate Law and store the result in x (using a reference vector).
Normal(RowVector const &mu, ArraySquareX const &sigma)
Constructor.
Real lpdf(RowVector const &x) const
compute the log probability distribution function.
ArraySquareX sigma_
The covariance parameter.
Real lnLikelihood(Array const &data) const
compute the log likehood of a data set.
RowVector const & mu() const
@return the location parameter
virtual void rand(RowVector &x) const
simulate a realization of the Multivariate Law and store the result in x.
ArraySquareX const & squareroot() const
@return the square root of the variance-covariance matrix
ArraySquareX squareroot_
The square root of the matrix Sigma_.
void setParameters(RowVector const &mu, ArraySquareX const &sigma)
update the parameters specific to the law.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Runtime errors represent problems outside the scope of a program; they cannot be easily predicted and...
Arrays::SumOp< Lhs, Rhs >::result_type sum(Lhs const &lhs, Rhs const &rhs)
convenience function for summing two arrays
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.