Accord.Math.Special.LogSum C# (CSharp) Method

LogSum() private method

private LogSum ( double lna, double lnc ) : double
lna double
lnc double
return double
        public static double LogSum(double lna, double lnc)
        {
            if (lna == Double.NegativeInfinity)
                return lnc;
            if (lnc == Double.NegativeInfinity)
                return lna;

            if (lna > lnc)
                return lna + Special.Log1p(Math.Exp(lnc - lna));

            return lnc + Special.Log1p(Math.Exp(lna - lnc));
        }

Same methods

Special::LogSum ( float lna, float lnc ) : double

Usage Example

コード例 #1
0
        public static double LogSumExp(this double[] array)
        {
            double sum = Double.NegativeInfinity;

            for (int i = 0; i < array.Length; i++)
            {
                sum = Special.LogSum(array[i], sum);
            }
            return(sum);
        }
All Usage Examples Of Accord.Math.Special::LogSum