private List <double> pearson()
        {
            PearsonCorrelation cor  = new PearsonCorrelation();
            List <double>      rets = new List <double>();
            int totElem             = values.Count - 12;

            double[] orig = new double[totElem];
            double[] sfas;
            for (int i = 0; i < orig.Length; i++)
            {
                orig[i] = values[i + 12];
            }

            for (int gap = 1; gap < 13; gap++)
            {
                sfas = new double[totElem];
                for (int i = 0; i < sfas.Length; i++)
                {
                    sfas[i] = values[i + 12 - gap];
                }
                double sim = cor.GetSimilarityScore(orig, sfas);
                rets.Add(sim);
            }

            return(rets);
        }
Example #2
0
        public void PearsonCorrelationTest( )
        {
            PearsonCorrelation sim = new PearsonCorrelation( );

            Assert.Throws <ArgumentException>(() => sim.GetSimilarityScore(p0, q4));

            double result = sim.GetSimilarityScore(p0, q0);

            Assert.AreEqual(result, -1);

            result = sim.GetSimilarityScore(p1, q1);
            Assert.AreEqual(result, 1);

            result = sim.GetSimilarityScore(p2, q2);
            Assert.AreEqual(result, 0);

            result = sim.GetSimilarityScore(p3, q3);
            Assert.AreEqual(result, 0);

            result = sim.GetSimilarityScore(p4, q4);
            Assert.AreApproximatelyEqual(result, 0.396059, 0.00001);

            result = sim.GetSimilarityScore(p5, q5);
            Assert.AreApproximatelyEqual(result, 0.85470, 0.00001);
        }
        /// <summary>
        /// Compute Pearson Correlation between each data column of the inputs and the identified data column of the output
        /// </summary>
        /// <param name="outputColumn">Indicates the column index of output data </param>
        /// <returns></returns>
        public double[] GetPearsonCorrelations(int outputColumn)
        {
            double[]           result = new double[InputVectorLength];
            PearsonCorrelation pc     = new PearsonCorrelation();

            for (int i = 0; i < InputVectorLength; i++)
            {
                result[i] = pc.GetSimilarityScore(this[i, true], this[outputColumn, false]);
            }
            return(result);
        }