/// <summary>
        /// Calculation method.
        /// </summary>
        /// <param name="chain">
        /// Source sequence.
        /// </param>
        /// <param name="link">
        /// Redundant parameter, not used in calculations.
        /// </param>
        /// <returns>
        /// Frequency of element in congeneric chain as <see cref="double"/>.
        /// </returns>
        public double Calculate(CongenericChain chain, Link link)
        {
            var count = new ElementsCount();
            var length = new Length();

            return count.Calculate(chain, link) / length.Calculate(chain, link);
        }
        /// <summary>
        /// Calculation method.
        /// </summary>
        /// <param name="chain">
        /// Source sequence.
        /// </param>
        /// <param name="link">
        /// Link of intervals in chain.
        /// </param>
        /// <returns>
        /// Average remoteness <see cref="double"/> value.
        /// </returns>
        public double Calculate(CongenericChain chain, Link link)
        {
            double depth = depthCalculator.Calculate(chain, link);
            int nj = (int)intervalsCount.Calculate(chain, link);

            return nj == 0 ? 0 : depth / nj;
        }
 /// <summary>
 /// Calculation method.
 /// </summary>
 /// <param name="firstChain">
 /// The first chain.
 /// </param>
 /// <param name="secondChain">
 /// The second chain.
 /// </param>
 /// <param name="link">
 /// The link.
 /// </param>
 /// <returns>
 /// The <see cref="double"/>.
 /// </returns>
 public double Calculate(CongenericChain firstChain, CongenericChain secondChain, Link link)
 {
     var partialAccordanceCalculator = new PartialComplianceDegree();
     var firstResult = partialAccordanceCalculator.Calculate(firstChain, secondChain, link);
     var secondResult = partialAccordanceCalculator.Calculate(secondChain, firstChain, link);
     return Math.Sqrt(firstResult * secondResult);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="AccordanceIntervalsManager"/> class.
        /// </summary>
        /// <param name="firstChain">
        /// The first chain.
        /// </param>
        /// <param name="secondChain">
        /// The second chain.
        /// </param>
        public AccordanceIntervalsManager(CongenericChain firstChain, CongenericChain secondChain)
        {
            this.firstChain = firstChain;
            this.secondChain = secondChain;
            Length = firstChain.GetLength();
            FirstOccurrencesCount = firstChain.OccurrencesCount;
            SecondOccurrencesCount = secondChain.OccurrencesCount;

            FillAccordanceIntervals();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BinaryIntervalsManager"/> class.
        /// </summary>
        /// <param name="firstChain">
        /// The first chain.
        /// </param>
        /// <param name="secondChain">
        /// The second chain.
        /// </param>
        public BinaryIntervalsManager(CongenericChain firstChain, CongenericChain secondChain)
        {
            FirstElement = firstChain.Element;
            SecondElement = secondChain.Element;
            FirstChain = firstChain;
            SecondChain = secondChain;
            Length = firstChain.GetLength();

            PairsCount = FillPairsCount();
            relationIntervals = new int[PairsCount];
            FillIntervals();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CongenericIntervalsManager"/> class.
        /// </summary>
        /// <param name="chain">
        /// The chain.
        /// </param>
        public CongenericIntervalsManager(CongenericChain chain)
        {
            var positions = chain.Positions;
            int count = positions.Length;

            // if sequence is empty
            if (count == 0)
            {
                throw new ArgumentException("Sequence should not be empty", "chain");
            }

            intervals = new int[count - 1];
            FillIntervals(positions, chain.GetLength());
        }
        /// <summary>
        /// Calculation method.
        /// </summary>
        /// <param name="chain">
        /// Source sequence.
        /// </param>
        /// <param name="link">
        /// Link of intervals in chain.
        /// </param>
        /// <returns>
        /// Variations count as <see cref="double"/>.
        /// </returns>
        public double Calculate(CongenericChain chain, Link link)
        {
            int count = 1;
            for (int i = 0; i < chain.GetLength(); i++)
            {
                var j = chain[i] as ValuePhantom;
                if (j != null)
                {
                    count *= ((ValuePhantom)chain[i]).Cardinality;
                }
            }

            return count;
        }
        /// <summary>
        /// Calculation methods.
        /// </summary>
        /// <param name="firstChain">
        /// The first chain.
        /// </param>
        /// <param name="secondChain">
        /// The second chain.
        /// </param>
        /// <param name="link">
        /// The link.
        /// </param>
        /// <returns>
        /// The <see cref="double"/>.
        /// </returns>
        public double Calculate(CongenericChain firstChain, CongenericChain secondChain, Link link)
        {
            var manager = new AccordanceIntervalsManager(firstChain, secondChain);
            if (manager.FilteredFirstIntervals.Count == 0)
            {
                return 0;
            }

            double result = 1;

            for (int i = 0; i < manager.FilteredFirstIntervals.Count; i++)
            {
                result *= LocalCompliance(manager.FilteredFirstIntervals[i], manager.FilteredSecondIntervals[i]);
            }

            double firstAndSecondOccurrences = manager.FirstOccurrencesCount + manager.SecondOccurrencesCount;

            double occurrencesCoefficient = 2.0 * manager.FilteredFirstIntervals.Count / firstAndSecondOccurrences;

            result = occurrencesCoefficient * Math.Pow(result, 1.0 / manager.FilteredFirstIntervals.Count);
            return result;
        }
 /// <summary>
 /// Calculation method.
 /// </summary>
 /// <param name="chain">
 /// Source sequence.
 /// </param>
 /// <param name="link">
 /// Link of intervals in chain.
 /// </param>
 /// <returns>
 /// Regularity as <see cref="double"/>.
 /// </returns>
 public double Calculate(CongenericChain chain, Link link)
 {
     return geometricMean.Calculate(chain, link) / descriptiveInformation.Calculate(chain, link);
 }
Пример #10
0
        /// <summary>
        /// Calculated as product of all intervals in sequence.
        /// </summary>
        /// <param name="chain">
        /// Source sequence.
        /// </param>
        /// <param name="link">
        /// Redundant parameter, not used in calculations.
        /// </param>
        /// <returns>
        /// Volume characteristic of chain as <see cref="double"/>.
        /// </returns>
        public double Calculate(CongenericChain chain, Link link)
        {
            var intervals = chain.GetIntervals(link);

            return intervals.Length == 0 ? 1 : intervals.Aggregate((result, interval) => result * interval);
        }
 /// <summary>
 /// Calculation method.
 /// </summary>
 /// <param name="chain">
 /// Source sequence.
 /// </param>
 /// <param name="link">
 /// Link of intervals in chain.
 /// </param>
 /// <returns>
 /// Descriptive informations count as <see cref="double"/>.
 /// </returns>
 public double Calculate(CongenericChain chain, Link link)
 {
     var calculator = new ArithmeticMean();
     double arithmeticMean = calculator.Calculate(chain, link);
     return arithmeticMean == 0 ? 1 : Math.Pow(arithmeticMean, 1 / arithmeticMean);
 }
        /// <summary>
        /// Logarithm of all intervals multiplied.
        /// </summary>
        /// <param name="chain">
        /// Source sequence.
        /// </param>
        /// <param name="link">
        /// Link of intervals in chain.
        /// </param>
        /// <returns>
        /// <see cref="double"/> value of alphabetic average remoteness.
        /// </returns>
        /// <exception cref="InvalidOperationException">
        /// Thrown if method is called not from <see cref="Calculate(Chain,Link)"/> and alphabet cardinality is unknown.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown if link is unknown.
        /// </exception>
        private double Calculate(CongenericChain chain, Link link)
        {
            int[] intervals = chain.GetIntervals(link);

            return intervals.Length == 0 ? 0 : intervals.Sum(interval => Math.Log(interval, alphabetCardinality));
        }
        /// <summary>
        /// Calculation method.
        /// </summary>
        /// <param name="chain">
        /// Source sequence.
        /// </param>
        /// <param name="link">
        /// Link of intervals in chain.
        /// </param>
        /// <returns>
        /// Average geometric of intervals lengths as <see cref="double"/>.
        /// </returns>
        public double Calculate(CongenericChain chain, Link link)
        {
            double remoteness = averageRemoteness.Calculate(chain, link);

            return Math.Pow(2, remoteness);
        }
Пример #14
0
 /// <summary>
 /// Calculation method.
 /// </summary>
 /// <param name="chain">
 /// Source sequence.
 /// </param>
 /// <param name="link">
 /// Redundant parameter, not used in calculations.
 /// </param>
 /// <returns>
 /// Chain length as <see cref="double"/>.
 /// </returns>
 public double Calculate(CongenericChain chain, Link link)
 {
     return chain.GetLength();
 }
        /// <summary>
        /// Calculation method.
        /// </summary>
        /// <param name="chain">
        /// Source sequence.
        /// </param>
        /// <param name="link">
        /// Link of intervals in chain.
        /// </param>
        /// <returns>
        /// Identification informations count as <see cref="double"/>.
        /// </returns>
        public double Calculate(CongenericChain chain, Link link)
        {
            double mean = arithmeticMean.Calculate(chain, link);

            return mean == 0 ? 0 : (-1 / mean) * Math.Log(1 / mean, 2);
        }
 /// <summary>
 /// Calculation method.
 /// </summary>
 /// <param name="chain">
 /// Source sequence.
 /// </param>
 /// <param name="link">
 /// Redundant parameter, not used in calculations.
 /// </param>
 /// <returns>
 /// Cut length as <see cref="double"/>.
 /// </returns>
 public double Calculate(CongenericChain chain, Link link)
 {
     return CutCommon(chain);
 }
 /// <summary>
 /// Calculation method for congeneric sequences.
 /// </summary>
 /// <param name="chain">
 /// The congeneric chain.
 /// </param>
 /// <param name="link">
 /// The link.
 /// </param>
 /// <returns>
 /// The <see cref="double"/>.
 /// </returns>
 public double Calculate(CongenericChain chain, Link link)
 {
     return entropyCalculator.Calculate(chain, link) - remotenessCalculator.Calculate(chain, link);
 }
 /// <summary>
 /// Amount of not empty positions, 
 /// in other words elements count.
 /// </summary>
 /// <param name="chain">
 /// Source sequence.
 /// </param>
 /// <param name="link">
 /// Redundant parameter, not used in calculations.
 /// </param>
 /// <returns>
 /// Elements count in chain as <see cref="double"/>.
 /// </returns>
 public double Calculate(CongenericChain chain, Link link)
 {
     return chain.OccurrencesCount;
 }
 /// <summary>
 /// Calculation method.
 /// </summary>
 /// <param name="chain">
 /// Source sequence.
 /// </param>
 /// <param name="link">
 /// Link of intervals in chain.
 /// </param>
 /// <returns>
 /// Periodicity as <see cref="double"/>.
 /// </returns>
 public double Calculate(CongenericChain chain, Link link)
 {
     return geometricMean.Calculate(chain, link) / arithmeticMean.Calculate(chain, link);
 }
 /// <summary>
 /// Calculation method.
 /// </summary>
 /// <param name="chain">
 /// Source sequence.
 /// </param>
 /// <param name="link">
 /// Redundant parameter, not used in calculations.
 /// </param>
 /// <returns>
 /// Cut length vocabulary entropy as <see cref="double"/>.
 /// </returns>
 public double Calculate(CongenericChain chain, Link link)
 {
     return Math.Log(chain.GetLength() - cutLength.Calculate(chain, link) + 1, 2);
 }
Пример #21
0
        /// <summary>
        /// Calculated as base 2 logarithm of multiplication 
        /// of intervals between nearest elements 
        /// in congeneric sequence.
        /// </summary>
        /// <param name="chain">
        /// Congeneric sequence.
        /// </param>
        /// <param name="link">
        /// Link of intervals in chain.
        /// </param>
        /// <returns>
        /// <see cref="double"/> value of depth.
        /// </returns>
        public double Calculate(CongenericChain chain, Link link)
        {
            var intervals = chain.GetIntervals(link);

            return intervals.Length == 0 ? 0 : intervals.Sum(interval => Math.Log(interval, 2));
        }
 /// <summary>
 /// Calculates multiplication of all intervals 
 /// between nearest elements in congeneric sequence
 /// divided by number of intervals.
 /// </summary>
 /// <param name="chain">
 /// Source sequence.
 /// </param>
 /// <param name="link">
 /// Link of intervals in chain.
 /// </param>
 /// <returns>
 /// <see cref="double"/> value of average arithmetic of intervals lengths.
 /// </returns>
 public double Calculate(CongenericChain chain, Link link)
 {
     double sum = adder.Calculate(chain, link);
     int intervalsCount = (int)counter.Calculate(chain, link);
     return intervalsCount == 0 ? 0 : sum / intervalsCount;
 }
 /// <summary>
 /// If link is to start, to end or cycle then intervals count equals elements count.
 /// If link is to start and end then intervals count equals elements count + 1.
 /// If link is none then intervals count equals elements count - 1.
 /// </summary>
 /// <param name="chain">
 /// Source sequence.
 /// </param>
 /// <param name="link">
 /// Link of intervals in chain.
 /// </param>
 /// <returns>
 /// Intervals count in chain as <see cref="double"/>.
 /// </returns>
 public double Calculate(CongenericChain chain, Link link)
 {
     return chain.GetIntervals(link).Length;
 }