This is less about accuracy (it is already good) but about getting rid of the General::munfl
messages. Before the final number is computed, we should check whether the logarithm of the result is below (a multiple of) Log[$MinMachineNumber]
; if yes, we simply set the result to 0
.
multinormalDens[x_, mean_, var_] := Module[{t, det, d=Length[mean]},
t = 0.5*(x - mean).LinearSolve[var, (x - mean)];
det = Det[(2*Pi)^d*var]^Det[2*Pi*var]^(0.5);
If[-t - Log[det] < 10. Log[$MinMachineNumber], 0., Exp[-t]/det]
];