Exemplo n.º 1
0
        public IΦHatResultElement Calculate(
            INormalFactory normalFactory,
            IΦHatResultElementFactory ΦHatResultElementFactory,
            IlIndexElement lIndexElement,
            IsIndexElement sIndexElement,
            IΛIndexElement ΛIndexElement,
            IExpectedValueΦ expectedValueΦ,
            IVarianceΦ varianceΦ,
            IVHat VHat,
            Iυ2 υ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(ΦHatResultElementFactory.Create(
                       sIndexElement,
                       lIndexElement,
                       ΛIndexElement,
                       (decimal)expectedValueΦ.GetElementAtAsdecimal(
                           sIndexElement,
                           lIndexElement,
                           ΛIndexElement)
                       +
                       (decimal)normal.CumulativeDistribution(
                           (double)(1 - υ2.GetElementAtAsdecimal(
                                        ΛIndexElement)))
                       *
                       (decimal)Math.Pow(
                           Math.Sqrt(
                               (double)VHat.GetElementAtAsdecimal(
                                   ΛIndexElement)),
                           -1)
                       *
                       (decimal)varianceΦ.GetElementAtAsdecimal(
                           sIndexElement,
                           lIndexElement,
                           ΛIndexElement)));
        }
Exemplo 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)));
        }