Esempio n. 1
0
 public IExpectedValueIResultElement Calculate(
     IExpectedValueIResultElementFactory expectedValueIResultElementFactory,
     ItIndexElement tIndexElement,
     IΛIndexElement ΛIndexElement,
     Il l,
     It t,
     Ist st,
     IExpectedValueΦ expectedValueΦ,
     Iz z)
 {
     return(expectedValueIResultElementFactory.Create(
                tIndexElement,
                ΛIndexElement,
                st.Value
                .Select(w =>
                        expectedValueΦ.GetElementAtAsdecimal(
                            w.sIndexElement,
                            l.GetElementAt(
                                tIndexElement.Key
                                -
                                w.tIndexElement.Key
                                +
                                (int)Math.Floor(
                                    (decimal)w.tIndexElement.Key
                                    /
                                    (tIndexElement.Key + 1))
                                *
                                t.GetT()),
                            ΛIndexElement)
                        *
                        z.GetElementAtAsint(
                            w.sIndexElement,
                            w.tIndexElement))
                .Sum()));
 }
Esempio n. 2
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)));
        }