예제 #1
0
        public void CalculateIntegralByDifferentTrapeze_Test()
        {
            double result = IntegralCalculation.CalculateIntegralByTrapeze(
                (x) => x * x, 2, -2, 0.01);

            Assert.AreEqual(16.0 / 3, result, 0.01);
        }
예제 #2
0
        /// <summary>
        /// Вычисляет функцию Лапласа.
        /// </summary>
        /// <param name="z">Значение.</param>
        /// <returns>Значение функции Лапласа.</returns>
        public double LaplasFunction(double z)
        {
            Func <double, double> funcBelowIntegral = (arg) => Math.Exp(-1 * arg * arg / 2);
            double result = 1 / Math.Sqrt(2 * Math.PI) *
                            IntegralCalculation.CalculateIntegralByTrapeze(
                funcBelowIntegral, z, -100, 0.1);

            return(result);
        }
예제 #3
0
        /// <summary>
        /// Вычисляет вероятность выполнения условия cond для значения x.
        /// </summary>
        /// <param name="x">Значение.</param>
        /// <param name="cond">Условие.</param>
        /// <returns>Вероятность.</returns>
        public double GetProbabilityWithCondition(double x, ConditionOfProbability cond)
        {
            double z = (x - average) / standDif;
            Func <double, double> funcBelowIntegral = (arg) => Math.Exp(-1 * arg * arg / 2);
            double result = 1 / Math.Sqrt(2 * Math.PI) *
                            IntegralCalculation.CalculateIntegralByTrapeze(
                funcBelowIntegral, z, -100, 0.1);

            if (cond == ConditionOfProbability.RandomVariableMoreThanX || cond == ConditionOfProbability.RandomVariableMoreOrEqualX)
            {
                result = 1 - result;
            }

            return(result);
        }