Exemplo n.º 1
0
        public IpParameterElement Create(
            IsIndexElement sIndexElement,
            IlIndexElement lIndexElement,
            IΛIndexElement ΛIndexElement,
            FhirDecimal value)
        {
            IpParameterElement parameterElement = null;

            try
            {
                parameterElement = new pParameterElement(
                    sIndexElement,
                    lIndexElement,
                    ΛIndexElement,
                    value);
            }
            catch (Exception exception)
            {
                this.Log.Error(
                    exception.Message,
                    exception);
            }

            return(parameterElement);
        }
        public IΦHatResultElement Create(
            IsIndexElement sIndexElement,
            IlIndexElement lIndexElement,
            IΛIndexElement ΛIndexElement,
            decimal value)
        {
            IΦHatResultElement resultElement = null;

            try
            {
                resultElement = new ΦHatResultElement(
                    sIndexElement,
                    lIndexElement,
                    ΛIndexElement,
                    value);
            }
            catch (Exception exception)
            {
                this.Log.Error(
                    exception.Message,
                    exception);
            }

            return(resultElement);
        }
Exemplo n.º 3
0
        public slCrossJoinElement(
            IsIndexElement sIndexElement,
            IlIndexElement lIndexElement)
        {
            this.sIndexElement = sIndexElement;

            this.lIndexElement = lIndexElement;
        }
Exemplo n.º 4
0
 public decimal GetElementAtAsdecimal(
     IpIndexElement pIndexElement,
     IlIndexElement lIndexElement)
 {
     return(this.Value
            .Where(x => x.pIndexElement == pIndexElement && x.lIndexElement == lIndexElement)
            .Select(x => x.Value.Value.Value)
            .SingleOrDefault());
 }
Exemplo n.º 5
0
        public probParameterElement(
            IpIndexElement pIndexElement,
            IlIndexElement lIndexElement,
            FhirDecimal value)
        {
            this.pIndexElement = pIndexElement;

            this.lIndexElement = lIndexElement;

            this.Value = value;
        }
Exemplo n.º 6
0
        public decimal GetElementAtAsdecimal(
            IsIndexElement sIndexElement,
            IlIndexElement lIndexElement,
            IΛIndexElement ΛIndexElement)
        {
            decimal value = this.Value
                            .Where(x => x.sIndexElement == sIndexElement && x.lIndexElement == lIndexElement && x.ΛIndexElement == ΛIndexElement)
                            .Select(x => x.Value.Value.Value)
                            .SingleOrDefault();

            return(value);
        }
        public IExpectedValueΦResultElement Calculate(
            IExpectedValueΦResultElementFactory expectedValueΦResultElementFactory,
            IlIndexElement lIndexElement,
            IsIndexElement sIndexElement,
            IΛIndexElement ΛIndexElement,
            Il l,
            It t,
            IL L,
            Ip p,
            Iμ μ)
        {
            int Ls = L.GetElementAtAsint(
                sIndexElement);

            int τLowerBound = 0;

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

            decimal sum = 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)
                {
                    sum +=
                        p.GetElementAtAsdecimal(
                            sIndexElement,
                            l.GetElementAt(
                                lPrime),
                            ΛIndexElement);
                }
            }

            return(expectedValueΦResultElementFactory.Create(
                       sIndexElement,
                       lIndexElement,
                       ΛIndexElement,
                       μ.GetElementAtAsdecimal(
                           sIndexElement,
                           ΛIndexElement)
                       *
                       sum));
        }
        public ΦHatParameterElement(
            IsIndexElement sIndexElement,
            IlIndexElement lIndexElement,
            IΛIndexElement ΛIndexElement,
            FhirDecimal value)
        {
            this.sIndexElement = sIndexElement;

            this.lIndexElement = lIndexElement;

            this.ΛIndexElement = ΛIndexElement;

            this.Value = value;
        }
Exemplo n.º 9
0
        public VarianceΦResultElement(
            IsIndexElement sIndexElement,
            IlIndexElement lIndexElement,
            IΛIndexElement ΛIndexElement,
            decimal value)
        {
            this.sIndexElement = sIndexElement;

            this.lIndexElement = lIndexElement;

            this.ΛIndexElement = ΛIndexElement;

            this.Value = value;
        }
        public IlIndexElement Create(
            PositiveInt value)
        {
            IlIndexElement indexElement = null;

            try
            {
                indexElement = new lIndexElement(
                    value);
            }
            catch (Exception exception)
            {
                this.Log.Error("Exception message: " + exception.Message + " and stacktrace " + exception.StackTrace);
            }

            return(indexElement);
        }
        public IslCrossJoinElement Create(
            IsIndexElement sIndexElement,
            IlIndexElement lIndexElement)
        {
            IslCrossJoinElement crossJoinElement = null;

            try
            {
                crossJoinElement = new slCrossJoinElement(
                    sIndexElement,
                    lIndexElement);
            }
            catch (Exception exception)
            {
                this.Log.Error("Exception message: " + exception.Message + " and stacktrace " + exception.StackTrace);
            }

            return(crossJoinElement);
        }
        public IlIndexElement Create(
            PositiveInt value)
        {
            IlIndexElement indexElement = null;

            try
            {
                indexElement = new lIndexElement(
                    value);
            }
            catch (Exception exception)
            {
                this.Log.Error(
                    exception.Message,
                    exception);
            }

            return(indexElement);
        }
Exemplo n.º 13
0
        public IslCrossJoinElement Create(
            IsIndexElement sIndexElement,
            IlIndexElement lIndexElement)
        {
            IslCrossJoinElement crossJoinElement = null;

            try
            {
                crossJoinElement = new slCrossJoinElement(
                    sIndexElement,
                    lIndexElement);
            }
            catch (Exception exception)
            {
                this.Log.Error(
                    exception.Message,
                    exception);
            }

            return(crossJoinElement);
        }
Exemplo n.º 14
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)));
        }
        public IExpectedValueΦResultElement Create(
            IsIndexElement sIndexElement,
            IlIndexElement lIndexElement,
            IΛIndexElement ΛIndexElement,
            decimal value)
        {
            IExpectedValueΦResultElement resultElement = null;

            try
            {
                resultElement = new ExpectedValueΦResultElement(
                    sIndexElement,
                    lIndexElement,
                    ΛIndexElement,
                    value);
            }
            catch (Exception exception)
            {
                this.Log.Error("Exception message: " + exception.Message + " and stacktrace " + exception.StackTrace);
            }

            return(resultElement);
        }
        public IpParameterElement Create(
            IsIndexElement sIndexElement,
            IlIndexElement lIndexElement,
            IΛIndexElement ΛIndexElement,
            FhirDecimal value)
        {
            IpParameterElement parameterElement = null;

            try
            {
                parameterElement = new pParameterElement(
                    sIndexElement,
                    lIndexElement,
                    ΛIndexElement,
                    value);
            }
            catch (Exception exception)
            {
                this.Log.Error("Exception message: " + exception.Message + " and stacktrace " + exception.StackTrace);
            }

            return(parameterElement);
        }
        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));
        }