INGOR
|
Statistical routines. More...
#include <math/ytStat.h>
Public Member Functions | |
double | ytStat_dnorm (double x, double m, double sd) |
Calculates the density function of the normal distribution. | |
void | ytStat_mvmean (const double *X, int n, int p, int N, double *mean) |
Calculates the mean of all the variables. | |
void | ytStat_mvcov (const double *X, int n, int p, int N, const double *m, double *S) |
Calculates the covariance matrix. | |
double | ytStat_mvdnorm (const double *x, int p, int N, const double *u, const double *Sinv, double detS) |
Calculates the density of the multivariate normal distribution. | |
double | ytStat_logmvdnorm (const double *x, int p, int N, const double *u, const double *Sinv, double logDetS) |
Calculates the log of multivariate normal distribution density. | |
Statistical routines.
double ytStat_dnorm | ( | double | x, |
double | m, | ||
double | sd | ||
) |
Calculates the density function of the normal distribution.
x | |
m | parameter mean |
sd | parameter sd (not variance σ2). |
double ytStat_logmvdnorm | ( | const double * | x, |
int | p, | ||
int | N, | ||
const double * | u, | ||
const double * | Sinv, | ||
double | logDetS | ||
) |
Calculates the log of multivariate normal distribution density.
See non-log version ytStat_mvdnorm() for details. Note that the determinant of Σ is given by log(|Σ|).
x | p input vector. |
p | dimension of x. |
N | stride of x. |
u | mean vector (μ). |
Sinv | Upper triangular symmetric matrix of inverse of the p by p covariance matrix (Σ-1). |
logDetS | log of determinant of the convariance matrix (log(|Σ|)). |
void ytStat_mvcov | ( | const double * | X, |
int | n, | ||
int | p, | ||
int | N, | ||
const double * | m, | ||
double * | S | ||
) |
Calculates the covariance matrix.
[in] | X | column major n by p input data matrix. Each column represents a set of samples of a variable. |
[in] | n | Number of rows (sampls) in X. |
[in] | p | Number of columns (variables) in X. |
[in] | N | Stride width of X. |
[in] | m | p mean vector where the j-th elemente represents the mean of the j -th variable. |
[out] | S | p by p upper triangular matrix where element s i,j ( i ≤ j ) represents covariance of the i -th and j -th column. |
double ytStat_mvdnorm | ( | const double * | x, |
int | p, | ||
int | N, | ||
const double * | u, | ||
const double * | Sinv, | ||
double | detS | ||
) |
Calculates the density of the multivariate normal distribution.
The mean vector can be calculated by ytStat_mvmean(), and the covariance matrix can be calculated by ytStat_mvcov().
The inverse of the covariance matrix Σ returned by ytStat_mvcov() can be calculated by ytMatrix_dsytrf() and ytMatrix_dsytri().
x | p input vector. |
p | dimension of input value x. |
u | mean vector (μ). |
Sinv | Upper triangular symmetric matrix of inverse of the p by p covariance matrix (Σ-1). |
detS | determinant of the covariance matrix (|Σ|). |
void ytStat_mvmean | ( | const double * | X, |
int | n, | ||
int | p, | ||
int | N, | ||
double * | mean | ||
) |
Calculates the mean of all the variables.
[in] | X | column major n by p input data matrix. Each column represents a set of samples of a variable. |
[in] | n | Number of rows (samples) in X. |
[in] | p | Number of columns (variables) in X. |
[in] | N | Stride width of X. |