예제 #1
0
파일: Copy.cs 프로젝트: mesgarpour/ERMER
        public static double AverageLogFactor(TruncatedGaussian copy, Gaussian value, Gaussian to_value)
        {
            var a = value / to_value;

            copy *= new TruncatedGaussian(a);
            return(value.GetAverageLog(value) - copy.GetAverageLog(copy));
        }
예제 #2
0
        public static double AverageLogFactor_helper([SkipIfUniform] Gaussian X, Gaussian to_X)
        {
            //if (!isPositive) throw new ArgumentException("VariationalMessagePassing requires isPositive=true", "isPositive");
            var prior = X / to_X;

            if (!prior.IsProper())
            {
                throw new ImproperMessageException(prior);
            }
            var tg = new TruncatedGaussian(prior);

            tg.LowerBound = 0;
            // Remove the incorrect Gaussian entropy contribution and add the correct
            // truncated Gaussian entropy. Log(1)=0 so the factor itself does not contribute.
            return(X.GetAverageLog(X) - tg.GetAverageLog(tg));
        }
		public static double AverageLogFactor_helper([SkipIfUniform] Gaussian X, Gaussian to_X)
		{
			//if (!isPositive) throw new ArgumentException("VariationalMessagePassing requires isPositive=true", "isPositive");
			var prior = X / to_X;
			if (!prior.IsProper()) throw new ImproperMessageException(prior);
			var tg = new TruncatedGaussian(prior);
			tg.LowerBound = 0;
			// Remove the incorrect Gaussian entropy contribution and add the correct
			// truncated Gaussian entropy. Log(1)=0 so the factor itself does not contribute. 
			return X.GetAverageLog(X) - tg.GetAverageLog(tg);
		}
예제 #4
0
		public static double AverageLogFactor(bool isBetween, [Stochastic] Gaussian X, double lowerBound, double upperBound, Gaussian to_X)
		{
			if (!isBetween) throw new ArgumentException("TruncatedGaussian requires isBetween=true", "isBetween");
			var prior = X / to_X;
			var tg = new TruncatedGaussian(prior);
			tg.LowerBound = lowerBound;
			tg.UpperBound = upperBound;
			return X.GetAverageLog(X) - tg.GetAverageLog(tg);
		}