SetDistributionParameters(
            int alpha,
            int beta)
        {
            if (!IsValidParameterSet(alpha, beta))
            {
                throw new ArgumentException(Properties.LocalStrings.ArgumentParameterSetInvalid);
            }

            _alpha = alpha;
            _beta  = beta;
            _chiSquaredAlpha.SetDistributionParameters(alpha);
            _chiSquaredBeta.SetDistributionParameters(beta);

            double alphaHalf = 0.5 * alpha;
            double betaHalf  = 0.5 * beta;

            _alphabeta = beta / (double)alpha;

            _pdfScaleLn =
                (alphaHalf * Math.Log(alpha))
                + (betaHalf * Math.Log(beta))
                - Fn.BetaLn(alphaHalf, betaHalf);
            _pdfExponent1 = alphaHalf - 1.0;
            _pdfExponent2 = -alphaHalf - betaHalf;
        }
Example #2
0
        SetDistributionParameters(
            int alpha,
            int beta
            )
        {
            if (!IsValidParameterSet(alpha, beta))
            {
                throw new ArgumentOutOfRangeException();
            }

            _alpha = alpha;
            _beta  = beta;
            _chiSquaredAlpha.SetDistributionParameters(alpha);
            _chiSquaredBeta.SetDistributionParameters(beta);

            double alphaHalf = 0.5 * alpha;
            double betaHalf  = 0.5 * beta;

            _alphabeta = (double)beta / (double)alpha;

            _pdfScaleLn =
                alphaHalf * Math.Log(alpha)
                + betaHalf * Math.Log(beta)
                - Fn.BetaLn(alphaHalf, betaHalf);
            _pdfExponent1 = alphaHalf - 1.0;
            _pdfExponent2 = -alphaHalf - betaHalf;
        }
Example #3
0
        SetDistributionParameters(int degreesOfFreedom)
        {
            if (!IsValidParameterSet(degreesOfFreedom))
            {
                throw new ArgumentException(Properties.LocalStrings.ArgumentParameterSetInvalid, "degreesOfFreedom");
            }

            _degreesOfFreedom = degreesOfFreedom;
            _chiSquareDistribution.SetDistributionParameters(degreesOfFreedom);

            double a    = 0.5 * (_degreesOfFreedom + 1);
            double nLn  = Fn.GammaLn(a);
            double dLn1 = Math.Log(Math.Sqrt(Math.PI * _degreesOfFreedom));
            double dLn2 = Fn.GammaLn(0.5 * _degreesOfFreedom);

            _exponent = -a;
            _factor   = Math.Exp(nLn - dLn1 - dLn2);
            _summand  = Fn.BetaRegularized(0.5 * _degreesOfFreedom, 0.5, 1);
        }