Beispiel #1
0
        private double IntegrateInner(double from, double to, double rho, double x)
        {
            double kronrodSum   = 0.0;
            double gaussSum     = 0.0;
            double y            = 0.0;
            double yt           = 0.0;
            double densityBN    = 0.0;
            double center       = (from + to) / 2.0;
            double halfDistance = to - center;

            for (int i = 0; i < abscissae.Length; i++)
            {
                y           = abscissae[i] * halfDistance + center;
                yt          = transform(y);
                densityBN   = BivariateStandardNormal.GetDensity(x, y, rho);
                kronrodSum += yt * densityBN * kronrodWeights[i];
                gaussSum   += yt * densityBN * gaussWeights[i];
            }

            kronrodSum = halfDistance * kronrodSum;
            gaussSum   = halfDistance * gaussSum;

            if (Math.Abs(kronrodSum - gaussSum) > TOLERANCE_INNER)
            {
                kronrodSum = IntegrateInner(from, center, rho, x) + IntegrateInner(center, to, rho, x);
            }
            return(kronrodSum);
        }
Beispiel #2
0
        private double IntegrateInner(double from, double to, double rho, double x)
        {
            var kronrodSum   = 0.0;
            var gaussSum     = 0.0;
            var y            = 0.0;
            var yt           = 0.0;
            var densityBN    = 0.0;
            var center       = (from + to) / 2.0;
            var halfDistance = to - center;

            for (var i = 0; i < abscissae.Length; i++)
            {
                y           = abscissae[i] * halfDistance + center;
                yt          = Transform(y);
                densityBN   = BivariateStandardNormal.GetDensity(x, y, rho);
                kronrodSum += yt * densityBN * kronrodWeights[i];
                gaussSum   += yt * densityBN * gaussWeights[i];
            }

            kronrodSum = halfDistance * kronrodSum;
            gaussSum   = halfDistance * gaussSum;

            if (System.Math.Abs(kronrodSum - gaussSum) > Tolerance_Inner)
            {
                kronrodSum = IntegrateInner(from, center, rho, x) + IntegrateInner(center, to, rho, x);
            }
            return(kronrodSum);
        }