I try to define the density of the multivariate normal distribution, as larger dimensions (vectors of 50 or more) can be computed faster, especially if these calculations have to be done frequently (10,000).
I defined the density as:
multi normal dens[x_, mean_, var_] : = Module[{},
Det[2*Pi*var]^ (- 0.5) * Exp[-0.5*(x - mean).Inverse[var](x - mean)]];
I use the Wishart to provide several positive defined covariance matrices.
varmat = RandomVariate[
WishartMatrixDistribution[52, IdentityMatrix[50]]10000];
meanmat = table[RandomReal[{0, 5}, 50], {i, 1, 10000}];
They are all evaluated for the same point:
x0 = RandomReal[{0, 5}, 50];
If I now perform the comparison for 10,000 experiments, I get:
in the[43]: = Table[
multinormalDens[x0, meanmat[[i]]varmat[[i]]]==
PDF[MultiNormalDistribution[meanmat[MultiNormalDistribution[meanmat[MultinormalDistribution[meanmat[MultinormalDistribution[meanmat[[i]]varmat[[i]]]x0]{1, 1,
length[varmat]}]// a total of
out[43]= 6643 Wrong + 3357 Right
How come I have 6643 different results? Are you from matrix inversion?
To edit:
Data = table[
multi normal dens[x0meanmat[x0meanmat[x0meanmat[x0meanmat[[i]]varmat[[i]]]-
PDF[MultiNormalDistribution[meanmat[MultiNormalDistribution[meanmat[MultinormalDistribution[meanmat[MultinormalDistribution[meanmat[[i]]varmat[[i]]]x0],
1, length[varmat]}];
ListPlot[data]