Log1p() private method

private Log1p ( double x ) : double
x double
return double
コード例 #1
0
        public static double LogSum(float lnx, float lny)
        {
            if (lnx == Single.NegativeInfinity)
            {
                return(lny);
            }
            if (lny == Single.NegativeInfinity)
            {
                return(lnx);
            }

            if (lnx > lny)
            {
                return(lnx + Special.Log1p(Math.Exp(lny - lnx)));
            }

            return(lny + Special.Log1p(Math.Exp(lnx - lny)));
        }
コード例 #2
0
        public static double LogSum(float lna, float lnc)
        {
            if (lna == Single.NegativeInfinity)
            {
                return(lnc);
            }
            if (lnc == Single.NegativeInfinity)
            {
                return(lna);
            }

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

            return(lnc + Special.Log1p(Math.Exp(lna - lnc)));
        }
コード例 #3
0
        public static double Log1pexp(double x)
        {
            // Computes Math.Log(1.0 / (1.0 + Math.Exp(-sum)));
            // https://cran.r-project.org/web/packages/Rmpfr/vignettes/log1mexp-note.pdf

            if (x < -37)
            {
                return(Math.Exp(x));
            }
            if (x <= 18)
            {
                return(Special.Log1p(Math.Exp(x)));
            }
            if (x <= 33)
            {
                return(x + Math.Exp(-x));
            }
            return(x);
        }
コード例 #4
0
ファイル: Normal.cs プロジェクト: mamimhk/accord-framework
 /// <summary>
 ///   Normal cumulative distribution function.
 /// </summary>
 ///
 /// <returns>
 ///   The area under the Gaussian p.d.f. integrated
 ///   from minus infinity to the given value.
 /// </returns>
 ///
 public static double Log(double value)
 {
     return(0.5 * Special.Log1p(Special.Erf(value / Constants.Sqrt2)));
 }