public IEBSResultElement Calculate(
            IEBSResultElementFactory EBSResultElementFactory,
            ItIndexElement tIndexElement,
            IΛIndexElement ΛIndexElement,
            IΩ Ω,
            IExpectedValueI ExpectedValueI,
            IVarianceI VarianceI)
        {
            int Ω_tΛ = Ω.Value.Value.Value;

            double ExpectedValueI_tΛ = (double)ExpectedValueI.GetElementAtAsdecimal(
                tIndexElement,
                ΛIndexElement);

            double VarianceI_tΛ = (double)VarianceI.GetElementAtAsdecimal(
                tIndexElement,
                ΛIndexElement);

            double lowerBound = Ω_tΛ + 0.5;

            double upperBound = double.PositiveInfinity;

            double value =
                0.5
                *
                (Ω_tΛ - ExpectedValueI_tΛ)
                *
                (MathNet.Numerics.SpecialFunctions.Erf(
                     (lowerBound - ExpectedValueI_tΛ)
                     *
                     Math.Pow(Math.Sqrt(2 * VarianceI_tΛ), -1))
                 -
                 MathNet.Numerics.SpecialFunctions.Erf(
                     (upperBound - ExpectedValueI_tΛ)
                     *
                     Math.Pow(Math.Sqrt(2 * VarianceI_tΛ), -1)))
                +
                Math.Sqrt(VarianceI_tΛ)
                *
                Math.Pow(Math.Sqrt(2 * Math.PI), -1)
                *
                (Math.Exp(
                     -Math.Pow(lowerBound - ExpectedValueI_tΛ, 2)
                     *
                     Math.Pow(2 * VarianceI_tΛ, -1))
                 -
                 Math.Exp(
                     -Math.Pow(upperBound - ExpectedValueI_tΛ, 2)
                     *
                     Math.Pow(2 * VarianceI_tΛ, -1)));

            return(EBSResultElementFactory.Create(
                       tIndexElement,
                       ΛIndexElement,
                       (decimal)value));
        }
Esempio n. 2
0
        public decimal Calculate(
            INormalFactory normalFactory,
            ItIndexElement tIndexElement,
            IΛIndexElement ΛIndexElement,
            IExpectedValueI expectedValueI,
            IVarianceI varianceI,
            decimal υ2)
        {
            // https://stackoverflow.com/questions/1662943/standard-normal-distribution-z-value-function-in-c-sharp
            MathNet.Numerics.Distributions.Normal normal = (MathNet.Numerics.Distributions.Normal)normalFactory.Create();

            return
                ((decimal)expectedValueI.GetElementAtAsdecimal(
                     tIndexElement,
                     ΛIndexElement)
                 +
                 (decimal)normal.CumulativeDistribution((double)(1 - υ2))
                 *
                 (decimal)Math.Sqrt(
                     (double)varianceI.GetElementAtAsdecimal(
                         tIndexElement,
                         ΛIndexElement)));
        }