public void MeanAbsoluteDifferenceTest()
 {
     var s1 = new Helpers.StatisticsHelper(new double[] { 1, 2, 3, 4, 5 });
     var s2 = new Helpers.StatisticsHelper(new double[] { 5, 4, 3, 2, 1 });
     double expected = 2.4;
     var actual = Helpers.StatisticsHelper.MeanAbsoluteDifference(s1, s2);
     Assert.AreEqual(expected, actual);
 }
 private double b(StatisticsHelper design)
 {
     return this.Mean - this.a(design) * design.Mean;
 }
 private double a(StatisticsHelper design)
 {
     try
     {
         return this.Covariance(design) / (Math.Pow(design.StandardDeviation, 2));
     }
     catch
     {
         return double.NaN;
     }
 }
 private double r(StatisticsHelper design)
 {
     try
     {
         return this.Covariance(design) / (this.StandardDeviation * design.StandardDeviation);
     }
     catch
     {
         return double.NaN;
     }
 }
        private double MeanAbsoluteDifference(StatisticsHelper design)
        {
            try
            {
                if (this.Length != design.Length) return double.NaN;

                var len = this.Length;
                double sumDiff = 0;

                for (var i = 0; i < len; i++)
                    sumDiff += Math.Abs(this._list[i] - design._list[i]);

                return sumDiff / len;
            }
            catch
            {
                return double.NaN;
            }
        }
        private double Covariance(StatisticsHelper s)
        {
            try
            {
                if (this.Length != s.Length) return double.NaN;
                var len = this.Length;
                double sumMul = 0;
                for (var i = 0; i <= len - 1; i++)
                    sumMul += (this._list[i] * s._list[i]);

                return (sumMul - len * this.Mean * s.Mean) / (len - 1);
            }
            catch
            {
                return double.NaN;
            }
        }
 public static double b(StatisticsHelper design1, StatisticsHelper design2)
 {
     return design1.Mean - a(design1, design2) * design2.Mean;
 }
 public static double a(StatisticsHelper design1, StatisticsHelper design2)
 {
     try
     {
         return Covariance(design1, design2) / (Math.Pow(design2.StandardDeviation, 2));
     }
     catch
     {
         return double.NaN;
     }
 }
 public static double r(StatisticsHelper design1, StatisticsHelper design2)
 {
     try
     {
         return Covariance(design1, design2) / (design1.StandardDeviation * design2.StandardDeviation);
     }
     catch
     {
         return double.NaN;
     }
 }
 public static double MeanAbsoluteDifference(StatisticsHelper s1, StatisticsHelper s2)
 {
     return s1.MeanAbsoluteDifference(s2);
 }
 public static double Covariance(StatisticsHelper s1, StatisticsHelper s2)
 {
     try
     {
         if (s1.Length != s2.Length) return double.NaN;
         var len = s1.Length;
         double sumMul = 0;
         for (var i = 0; i <= len - 1; i++)
             sumMul += (s1._list[i] * s2._list[i]);
         return (sumMul - len * s1.Mean * s2.Mean) / (len - 1);
     }
     catch
     {
         return double.NaN;
     }
 }