Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="first"></param>
        /// <param name="second"></param>
        /// <param name="percentile">desiered percental rank (in range 0...1)</param>
        /// <remarks>Set <cref="percentile"/> with less to <c="0"/> to elliminate selection by percentile rank.</remarks>
        private double Accordance(RecordsNodesCircularList <TPosition> first, RecordsNodesCircularList <TPosition> second, double percentile)
        {
            double res = 0;

            if (!IsCorrelated)
            {
                throw new Exception("Accodance terminated! Launch 'Correlate(...)' method first and then try again. CAUSE: Records collactions are NOT correlated yet.");
            }

            RecordNode <Record <TPosition> > itrtrFirst  = first.Head;
            RecordNode <Record <TPosition> > itrtrSecond = second.Head;

            Delta <TPosition>         delta        = null;
            List <Delta <TPosition> > deltas       = null;
            List <Delta <TPosition> > deltasSorted = null;

            do
            {
                delta = new Delta <TPosition>(itrtrFirst, itrtrSecond);

                if (deltas == null)
                {
                    deltas = new List <Delta <TPosition> >();
                }
                deltas.Add(delta);

                if (deltasSorted == null)
                {
                    deltasSorted = new List <Delta <TPosition> >();
                }
                deltasSorted.Add(delta);

                itrtrFirst  = itrtrFirst.Next;
                itrtrSecond = itrtrSecond.Next;
            }while (itrtrFirst != first.Head);

            if (PercentRank(deltasSorted))
            {
                int endIndx = deltasSorted.Count;

                if (percentile >= 0)
                {
                    int i = 0;
                    for (; i < endIndx && deltasSorted.ElementAt(i).PercentRank.HasValue&& deltasSorted.ElementAt(i).PercentRank.Value < percentile; i++)
                    {
                    }
                    endIndx = i;
                }
                res = deltasSorted.StandardDeviation(0, endIndx);
            }
            return(res);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="first"></param>
        /// <param name="second"></param>
        /// <returns></returns>
        public string Corellate(string first, string second)
        {
            string res = null;

            RecordsNodesCircularList <TPosition> rnclFirst = RecordsNodesCircularList <TPosition> .Deserialize(_widthLimit, first);

            RecordsNodesCircularList <TPosition> rnclSecond = RecordsNodesCircularList <TPosition> .Deserialize(_widthLimit, second);

            Corellate(rnclFirst, rnclSecond);

            if (rnclSecond.IsAdjusted)
            {
                RecordsNodesCircularList <TPosition> .Serialize(first, rnclFirst, rnclSecond);

                res = first;
            }

            return(res);
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="first"></param>
        /// <param name="second"></param>
        /// <returns></returns>
        public void Corellate(RecordsNodesCircularList <TPosition> first, RecordsNodesCircularList <TPosition> second)
        {
            if (first == null || second == null)
            {
                throw new ArgumentNullException(first == null ? "first" : "second");
            }

            if (first.Count != second.Count)
            {
                throw new ArgumentException($"Different members quantity for {nameof(first)}({first.Count}) and {nameof(second)}({second.Count})");
            }

            _base   = first;
            _second = second;

            try
            {
                IsCorrelated = _base.Adjust(_second);
            }
            catch (ArgumentException ex)
            {
                throw ex;
            }
        }