/// <summary> /// Predictive Variance at a given point /// </summary> /// <param name="X">Input</param> /// <returns>Predictive variance</returns> public double Variance(Vector X) { if (IsUniform()) { Gaussian temp = new Gaussian(); temp.SetToUniform(); return(temp.GetVariance()); } else { Vector kxB = FixedParameters.KernelOf_X_B(X); return(FixedParameters.Prior.Variance(X) - Beta.QuadraticForm(kxB)); } }
/// <summary> /// The maximum difference between the parameters of this Gaussian /// and that Gaussian /// </summary> /// <param name="thatd">That Gaussian</param> /// <returns>The maximum difference</returns> /// <remarks><c>a.MaxDiff(b) == b.MaxDiff(a)</c></remarks> public double MaxDiff(object thatd) { if (!(thatd is Gaussian)) { return(Double.PositiveInfinity); } Gaussian that = (Gaussian)thatd; #if true double diff1 = MMath.AbsDiff(MeanTimesPrecision, that.MeanTimesPrecision); double diff2 = MMath.AbsDiff(Precision, that.Precision); #else double diff1 = Math.Abs(GetMean() - that.GetMean()); double diff2 = Math.Abs(Math.Sqrt(GetVariance()) - Math.Sqrt(that.GetVariance())); #endif return(Math.Max(diff1, diff2)); }