示例#1
0
        internal override double LogFSecond(double mu, SGNFnAParam A)
        {
            double     z     = mu / A.S;
            LPhiObject lphio = WebExpoFunctions3.LPhi(z);

            return(A.N / A.S2 * (z * lphio.R[0] + lphio.R2[0] - 1));
        }
示例#2
0
        internal static LPhiObject LPhi(double[] z)
        {
            //# z: can be scalar or vector
            LPhiObject rep = new LPhiObject(z.Length);

            /*
             *  lphi <- function(z)
             *  {
             # z: can be scalar or vector
             #
             #    log.phi <- dnorm(z, log=T)      # log(phi(z))
             #    log.Phi <- pnorm(z, log.p=T)    # log(Phi(z))
             #
             #    r  <- exp(log.phi-log.Phi)      # phi(z)/Phi(z)
             #    r2 <- exp(2*(log.phi-log.Phi))  # phi^2(z) / Phi^2 (z)
             #
             #    list(r=r, r2=r2) # r and r2 are of same length as z
             #  } # end of lphi
             */

            double[] tmp = NormalDistribution.DNorm(z, give_log: true).Substract(NormalDistribution.PNorm(z, log_p: true));
            rep.R  = tmp.Exp();             // phi(z)/Phi(z)
            rep.R2 = tmp.Multiply(2).Exp(); // phi^2(z) / Phi^2 (z)
            return(rep);
        }
示例#3
0
        internal override double LogFPrime(double mu, SGNFnAParam A)
        {
            double     z     = mu / A.S;
            LPhiObject lphio = WebExpoFunctions3.LPhi(z);

            return(-A.N * (mu - A.MuMean) / A.S2 - A.N * lphio.R[0] / A.S);
        }
示例#4
0
        internal override double LogFSecond(double s, SGNFnAParam A)
        {
            double     z = A.Mu / s;
            LPhiObject l = WebExpoFunctions3.LPhi(z);

            return(A.N / Math.Pow(s, 2) - 6.0 * A.B / Math.Pow(s, 4) + A.N * z * ((Math.Pow(z, 2) - 2.0) * l.R[0] + z * l.R2[0]) / Math.Pow(s, 2));
        }
示例#5
0
        internal override double LogFPrime(double s, SGNFnAParam A)
        {
            double     z = A.Mu / s;
            LPhiObject l = WebExpoFunctions3.LPhi(z);

            return(-A.N / s + 2.0 * A.B / Math.Pow(s, 3) + A.N * z * l.R[0] / s);
        }
示例#6
0
        internal override double LogFPrime(double v, SGNFnAParam A)
        {
            LPhiObject l = WebExpoFunctions3.LPhi(1 / v);

            return
                (-A.N / v
                 + 2.0 * A.B / Math.Pow(v, 3)
                 + A.N * l.R[0] / Math.Pow(v, 2));
        }
示例#7
0
        internal override double LogFSecond(double s, SGNFnAParam A)
        {
            //    log.f.prime <- function(s, A){z <- exp(s)/A$ksi; l <- lphi(z); -l$r*z + A$y*z/A$ksi - z^2 - (s-A$mu)/A$sigma2}
            double[]   z     = new double[] { Math.Exp(s) / A.Ksi };
            LPhiObject lphio = WebExpoFunctions3.LPhi(z);
            double     r0    = lphio.R[0];
            double     z0    = z[0];

            return(r0 * (Math.Pow(z0, 3) - z[0]) + Math.Pow(r0 * z0, 2) + (A.Y * Math.Exp(s) - 2.0 * Math.Exp(2 * s)) / A.Ksi2 - 1.0 / A.Sigma2);
        }
示例#8
0
        internal override double LogFSecond(double v, SGNFnAParam A)
        {
            LPhiObject l  = WebExpoFunctions3.LPhi(1 / v);
            double     v2 = Math.Pow(v, 2);
            double     v4 = Math.Pow(v2, 2);

            return
                (A.N / v2
                 - 6.0 * A.B / v4
                 + A.N / v4 * (l.R[0] * (1 / v - 2.0 * v) + l.R2[0]));
        }
示例#9
0
        internal override double LogFPrime(double s, SGNFnAParam A)
        {
            double     z = A.Mu / s;
            LPhiObject l = WebExpoFunctions3.LPhi(z);

            return
                (-(A.N + 1.0) / s
                 + 2.0 * A.B / Math.Pow(s, 3)
                 - (Math.Log(s) - A.LM) / A.LS2 / s
                 + A.N * z * l.R[0] / s);
        }
示例#10
0
        internal override double LogFPrime(double s, SGNFnAParam A)
        {
            //    log.f.prime <- function(s, A){z <- exp(s)/A$ksi; l <- lphi(z); -l$r*z + A$y*z/A$ksi - z^2 - (s-A$mu)/A$sigma2}
            double     z     = Math.Exp(s) / A.Ksi;
            LPhiObject lphio = WebExpoFunctions3.LPhi(z);

            return
                (-lphio.R[0] * z
                 + A.Y * z / A.Ksi
                 - Math.Pow(z, 2) - (s - A.Mu) / A.Sigma2);
        }