public static Prod ( |
||
v | A variable-length parameters list containing v. | |
Résultat | double |
/// <summary>A Vector extension method that products the given v.</summary> /// <param name="v">The v to act on.</param> /// <returns>A double.</returns> public static double Prod(this Vector v) { return(Vector.Prod(v)); }
/// <summary>Compute probability according to multivariate Gaussian.</summary> /// <param name="x">Vector in question.</param> /// <param name="mu">Mean.</param> /// <param name="sigma">diag(covariance)</param> /// <returns>Probability.</returns> public double Normal(Vector x, Vector mu, Vector sigma) { var p = 1 / sqrt(pow(2 * System.Math.PI, mu.Length) * sigma.Prod()); var exp = -0.5d * ((x - mu) * sigma.Each(d => 1 / d, true)).Dot(x - mu); var e_exp = pow(System.Math.E, exp); return p * e_exp; }