/// <summary> /// Returns the maximum difference between the parameters of this sparse Gaussian list /// and another /// </summary> /// <param name="thatd">The other sparse Gaussian list</param> /// <returns>The maximum difference</returns> /// <remarks><c>a.MaxDiff(b) == b.MaxDiff(a)</c></remarks> public double MaxDiff(object thatd) { SparseGaussianList that = (SparseGaussianList)thatd; return(Reduce <double, Gaussian>( double.NegativeInfinity, that, (x, y, z) => Math.Max(x, y.MaxDiff(z)))); }
/// <summary> /// Creates a sparse Gaussian list of a given size, with given mean and precision vectors. /// </summary> /// <param name="mean">The desired mean.</param> /// <param name="precision">The desired precision.</param> /// <param name="tolerance">The tolerance for the approximation</param> public static SparseGaussianList FromMeanAndPrecision( IList <double> mean, IList <double> precision, double tolerance) { var result = new SparseGaussianList(mean.Count, tolerance); result.SetToFunction(mean, precision, (m, p) => Gaussian.FromMeanAndPrecision(m, p)); return(result); }
/// <summary> /// Copy constructor /// </summary> /// <param name="that"></param> protected SparseGaussianList(SparseGaussianList that) : base(that) { }
/// <summary> /// The expected logarithm of that sparse Gaussian list under this sparse Gaussian list. /// </summary> /// <param name="that"></param> /// <returns></returns> public double GetAverageLog(SparseGaussianList that) { return(Reduce <double, Gaussian>(0.0, that, (x, y, z) => x + y.GetAverageLog(z))); }
/// <summary> /// Returns the log of the integral of the product of this sparse Gaussian list and another sparse Gaussian list raised to a power /// </summary> /// <param name="that"></param> public double GetLogAverageOfPower(SparseGaussianList that, double power) { return(Reduce <double, Gaussian>(0.0, that, (x, y, z) => x + y.GetLogAverageOfPower(z, power))); }
/// <summary> /// Creates a sparse Gaussian list whose elements match the means and variances /// of the weighted sums of the elements of two other sparse Gaussian lists. /// </summary> /// <param name="weight1">The first weight</param> /// <param name="value1">The first sparse Gaussian list</param> /// <param name="weight2">The second weight</param> /// <param name="value2">The second sparse Gaussian list</param> public void SetToSum(double weight1, SparseGaussianList value1, double weight2, SparseGaussianList value2) { SetToFunction(value1, value2, (g1, g2) => { var g = new Gaussian(); g.SetToSum(weight1, g1, weight2, g2); return(g); }); }
/// <summary> /// Sets this sparse Gaussian list to the ratio of two other sparse Gaussian lists /// </summary> /// <param name="numerator"></param> /// <param name="denominator"></param> public void SetToRatio(SparseGaussianList numerator, SparseGaussianList denominator) { SetToFunction(numerator, denominator, (gn, gd) => gn / gd); }
/// <summary> /// Sets this sparse Gaussian list to the power of another sparse Gaussian list /// </summary> /// <param name="value"></param> /// <param name="exponent"></param> public void SetToPower(SparseGaussianList value, double exponent) { SetToFunction(value, g => g ^ exponent); }
/// <summary> /// Sets this sparse Gaussian list to the product of two other sparse Gaussian lists /// </summary> /// <param name="a"></param> /// <param name="b"></param> public void SetToProduct(SparseGaussianList a, SparseGaussianList b) { SetToFunction(a, b, (ga, gb) => ga * gb); }
/// <summary> /// Sets this sparse Gaussian list to another sparse Gaussian list /// </summary> /// <param name="value"></param> public void SetTo(SparseGaussianList value) { base.SetTo(value); }