//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void test()
        public virtual void test()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double x = RANDOM.nextDouble();
            double x = RANDOM.NextDouble();

            assertEquals(Math.Log(GAMMA.applyAsDouble(x)), LN_GAMMA.apply(x), EPS);
        }
Пример #2
0
        /// <summary>
        /// {@inheritDoc}
        /// </summary>
        public virtual GaussianQuadratureData generate(int n)
        {
            ArgChecker.isTrue(n > 0, "n > 0");
            Pair <DoubleFunction1D, DoubleFunction1D>[] polynomials = JACOBI.getPolynomialsAndFirstDerivative(n, _alpha, _beta);
            Pair <DoubleFunction1D, DoubleFunction1D>   pair        = polynomials[n];
            DoubleFunction1D previous   = polynomials[n - 1].First;
            DoubleFunction1D function   = pair.First;
            DoubleFunction1D derivative = pair.Second;

            double[] x    = new double[n];
            double[] w    = new double[n];
            double   root = 0;

            for (int i = 0; i < n; i++)
            {
                double d = 2 * n + _c;
                root = getInitialRootGuess(root, i, n, x);
                root = ROOT_FINDER.getRoot(function, derivative, root).Value;
                x[i] = root;
                w[i] = GAMMA_FUNCTION.applyAsDouble(_alpha + n) * GAMMA_FUNCTION.applyAsDouble(_beta + n) / CombinatoricsUtils.factorialDouble(n) / GAMMA_FUNCTION.applyAsDouble(n + _c + 1) * d * Math.Pow(2, _c) / (derivative.applyAsDouble(root) * previous.applyAsDouble(root));
            }
            return(new GaussianQuadratureData(x, w));
        }
 /// <summary>
 /// {@inheritDoc}
 /// </summary>
 public virtual double getInverseCDF(double?p)
 {
     ArgChecker.notNull(p, "p");
     ArgChecker.isTrue(p >= 0 && p <= 1, "Probability must lie between 0 and 1");
     return(2 * _inverseFunction.applyAsDouble(0.5 * _degrees, p));
 }
Пример #4
0
 //-------------------------------------------------------------------------
 public double value(T trade, RatesProvider provider)
 {
     return(valueFn.applyAsDouble(trade, provider));
 }