コード例 #1
0
 public IVarianceΦ Calculate(
     IVarianceΦResultElementFactory varianceΦResultElementFactory,
     IVarianceΦFactory varianceΦFactory,
     IVarianceΦResultElementCalculation varianceΦResultElementCalculation,
     Il l,
     It t,
     IslΛ slΛ,
     IL L,
     Ip p,
     Iμ μ,
     Iσ σ)
 {
     return(varianceΦFactory.Create(
                slΛ.Value
                .Select(i => varianceΦResultElementCalculation.Calculate(
                            varianceΦResultElementFactory,
                            i.lIndexElement,
                            i.sIndexElement,
                            i.ΛIndexElement,
                            l,
                            t,
                            L,
                            p,
                            μ,
                            σ))
                .ToImmutableList()));
 }
コード例 #2
0
        public IVarianceΦResultElementFactory CreateVarianceΦResultElementFactory()
        {
            IVarianceΦResultElementFactory factory = null;

            try
            {
                factory = new VarianceΦResultElementFactory();
            }
            catch (Exception exception)
            {
                this.Log.Error("Exception message: " + exception.Message + " and stacktrace " + exception.StackTrace);
            }

            return(factory);
        }
コード例 #3
0
        public IVarianceΦResultElementFactory CreateVarianceΦResultElementFactory()
        {
            IVarianceΦResultElementFactory factory = null;

            try
            {
                factory = new VarianceΦResultElementFactory();
            }
            catch (Exception exception)
            {
                this.Log.Error(
                    exception.Message,
                    exception);
            }

            return(factory);
        }
コード例 #4
0
        public IVarianceΦResultElement Calculate(
            IVarianceΦResultElementFactory varianceΦResultElementFactory,
            IlIndexElement lIndexElement,
            IsIndexElement sIndexElement,
            IΛIndexElement ΛIndexElement,
            Il l,
            It t,
            IL L,
            Ip p,
            Iμ μ,
            Iσ σ)
        {
            int Ls = L.GetElementAtAsint(
                sIndexElement);

            int τLowerBound = 0;

            int τUpperBound = (int)Math.Floor(
                (decimal)
                (Ls - lIndexElement.Value.Value.Value)
                /
                t.GetT());

            // Mean
            decimal meanSum = 0;

            for (int τ = τLowerBound; τ <= τUpperBound; τ = τ + 1)
            {
                int lPrimeLowerBound = lIndexElement.Value.Value.Value + τ * t.GetT() + 1;

                int lPrimeVarianceUpperBound = Math.Min(
                    lIndexElement.Value.Value.Value + τ * t.GetT() + t.GetT(),
                    Ls);

                int lPrimeCovarianceUpperBound = Math.Min(
                    lIndexElement.Value.Value.Value + τ * t.GetT() + t.GetT(),
                    Ls - 1);

                // Mean: Variance
                for (int lPrime = lPrimeLowerBound; lPrime <= lPrimeVarianceUpperBound; lPrime = lPrime + 1)
                {
                    meanSum +=
                        (τ + 1)
                        *
                        p.GetElementAtAsdecimal(
                            sIndexElement,
                            l.GetElementAt(
                                lPrime),
                            ΛIndexElement)
                        *
                        (1 - p.GetElementAtAsdecimal(
                             sIndexElement,
                             l.GetElementAt(
                                 lPrime),
                             ΛIndexElement));
                }

                // Mean: Covariance
                for (int lPrime = lPrimeLowerBound; lPrime <= lPrimeCovarianceUpperBound; lPrime = lPrime + 1)
                {
                    int lHatLowerBound = lPrime + 1;

                    int lHatUpperBound = Ls;

                    for (int lHat = lHatLowerBound; lHat <= lHatUpperBound; lHat = lHat + 1)
                    {
                        meanSum -=
                            (τ + 1)
                            *
                            2
                            *
                            p.GetElementAtAsdecimal(
                                sIndexElement,
                                l.GetElementAt(
                                    lPrime),
                                ΛIndexElement)
                            *
                            p.GetElementAtAsdecimal(
                                sIndexElement,
                                l.GetElementAt(
                                    lHat),
                                ΛIndexElement);
                    }
                }
            }

            // Variance
            decimal varianceSum = 0;

            for (int τ = τLowerBound; τ <= τUpperBound; τ = τ + 1)
            {
                int lPrimeLowerBound = lIndexElement.Value.Value.Value + τ * t.GetT() + 1;

                int lPrimeUpperBound = Ls;

                for (int lPrime = lPrimeLowerBound; lPrime <= lPrimeUpperBound; lPrime = lPrime + 1)
                {
                    varianceSum +=
                        p.GetElementAtAsdecimal(
                            sIndexElement,
                            l.GetElementAt(
                                lPrime),
                            ΛIndexElement);
                }
            }

            return(varianceΦResultElementFactory.Create(
                       sIndexElement,
                       lIndexElement,
                       ΛIndexElement,
                       μ.GetElementAtAsdecimal(
                           sIndexElement,
                           ΛIndexElement)
                       *
                       meanSum
                       +
                       σ.GetElementAtAsdecimal(
                           sIndexElement,
                           ΛIndexElement)
                       *
                       σ.GetElementAtAsdecimal(
                           sIndexElement,
                           ΛIndexElement)
                       *
                       varianceSum
                       *
                       varianceSum));
        }
コード例 #5
0
        public IΦHat Calculate(
            IExpectedValueIResultElementCalculationFactory expectedValueIResultElementCalculationFactory,
            IExpectedValueΦResultElementCalculationFactory expectedValueΦResultElementCalculationFactory,
            IVarianceIResultElementCalculationFactory varianceIResultElementCalculationFactory,
            IVarianceΦResultElementCalculationFactory varianceΦResultElementCalculationFactory,
            IVHatResultElementCalculationFactory VHatResultElementCalculationFactory,
            Iυ2ResultElementCalculationFactory υ2ResultElementCalculationFactory,
            IΦHatResultElementCalculationFactory ΦHatResultElementCalculationFactory,
            IExpectedValueICalculationFactory expectedValueICalculationFactory,
            IExpectedValueΦCalculationFactory expectedValueΦCalculationFactory,
            IMRNBCalculationFactory MRNBCalculationFactory,
            IRNBCalculationFactory RNBCalculationFactory,
            ItStarCalculationFactory tStarCalculationFactory,
            IVarianceICalculationFactory varianceICalculationFactory,
            IVarianceΦCalculationFactory varianceΦCalculationFactory,
            IVHatCalculationFactory VHatCalculationFactory,
            Iυ2CalculationFactory υ2CalculationFactory,
            INormalFactory normalFactory,
            IExpectedValueIResultElementFactory expectedValueIResultElementFactory,
            IExpectedValueΦResultElementFactory expectedValueΦResultElementFactory,
            IVarianceIResultElementFactory varianceIResultElementFactory,
            IVarianceΦResultElementFactory varianceΦResultElementFactory,
            IVHatResultElementFactory VHatResultElementFactory,
            Iυ2ResultElementFactory υ2ResultElementFactory,
            IΦHatResultElementFactory ΦHatResultElementFactory,
            IExpectedValueIFactory expectedValueIFactory,
            IExpectedValueΦFactory expectedValueΦFactory,
            IVarianceIFactory varianceIFactory,
            IVarianceΦFactory varianceΦFactory,
            IVHatFactory VHatFactory,
            Iυ2Factory υ2Factory,
            IΦHatFactory ΦHatFactory,
            Il l,
            It t,
            IΛ Λ,
            IslΛ slΛ,
            Ist st,
            ItΛ tΛ,
            IL L,
            Ip p,
            Iμ μ,
            Iσ σ,
            IΩ Ω,
            Iz z)
        {
            // ExpectedValueΦ
            IExpectedValueΦ expectedValueΦ = expectedValueΦCalculationFactory.Create()
                                             .Calculate(
                expectedValueΦResultElementFactory,
                expectedValueΦFactory,
                expectedValueΦResultElementCalculationFactory.Create(),
                l,
                t,
                slΛ,
                L,
                p,
                μ);

            // VarianceΦ
            IVarianceΦ varianceΦ = varianceΦCalculationFactory.Create()
                                   .Calculate(
                varianceΦResultElementFactory,
                varianceΦFactory,
                varianceΦResultElementCalculationFactory.Create(),
                l,
                t,
                slΛ,
                L,
                p,
                μ,
                σ);

            // ExpectedValueI
            IExpectedValueI expectedValueI = expectedValueICalculationFactory.Create()
                                             .Calculate(
                expectedValueIResultElementFactory,
                expectedValueIFactory,
                expectedValueIResultElementCalculationFactory.Create(),
                l,
                t,
                st,
                tΛ,
                expectedValueΦ,
                z);

            // VarianceI
            IVarianceI varianceI = varianceICalculationFactory.Create()
                                   .Calculate(
                varianceIResultElementFactory,
                varianceIFactory,
                varianceIResultElementCalculationFactory.Create(),
                l,
                t,
                st,
                tΛ,
                varianceΦ,
                z);

            // υ2
            Iυ2 υ2 = υ2CalculationFactory.Create()
                     .Calculate(
                normalFactory,
                υ2ResultElementFactory,
                υ2Factory,
                MRNBCalculationFactory.Create(),
                RNBCalculationFactory.Create(),
                υ2ResultElementCalculationFactory.Create(),
                t,
                Λ,
                Ω,
                expectedValueI,
                varianceI);

            // VHat
            IVHat VHat = VHatCalculationFactory.Create()
                         .Calculate(
                normalFactory,
                VHatResultElementFactory,
                VHatFactory,
                RNBCalculationFactory.Create(),
                tStarCalculationFactory.Create(),
                VHatResultElementCalculationFactory.Create(),
                t,
                Λ,
                expectedValueI,
                varianceI,
                υ2);

            return(this.Calculate(
                       normalFactory,
                       ΦHatResultElementFactory,
                       ΦHatFactory,
                       ΦHatResultElementCalculationFactory.Create(),
                       slΛ,
                       expectedValueΦ,
                       varianceΦ,
                       VHat,
                       υ2));
        }