Exemplo n.º 1
0
        public Mean Copy()
        {
            Mean result = new Mean();

            Copy(this, result);
            return(result);
        }
Exemplo n.º 2
0
        public double GetCovarianve(double[] xArray, double[] yArray, bool biasCorrected) //throws MathIllegalArgumentException
        {
            Mean   mean   = new Mean();
            double result = 0.0D;
            int    length = xArray.Length;

            if (length != yArray.Length)
            {
                // throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, new Object[] { Integer.valueOf(length), Integer.valueOf(yArray.length)
            }

            if (length < 2)
            {
                //throw new MathIllegalArgumentException(LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE, new Object[] { Integer.valueOf(length), Integer.valueOf(2) });
            }
            double xMean = mean.Evaluate(xArray);
            double yMean = mean.Evaluate(yArray);

            for (int i = 0; i < length; i++)
            {
                double xDev = xArray[i] - xMean;
                double yDev = yArray[i] - yMean;
                result += (xDev * yDev - result) / (i + 1);
            }
            return(biasCorrected ? result * (length / (length - 1)) : result);
        }
Exemplo n.º 3
0
 public static void Copy(Mean source, Mean dest)
 {
     MathUtils.checkNotNull(source);
     MathUtils.checkNotNull(dest);
     dest.SetData(source.GetDataRef());
     dest.incMoment = source.incMoment;
     dest.moment    = source.moment.Copy();
 }
Exemplo n.º 4
0
        public double Evaluate(double[] values, int begin, int length) //throws MathIllegalArgumentException
        {
            double var = Double.NaN;

            if (Test(values, begin, length))
            {
                Clear();
                if (length == 1)
                {
                    var = 0.0D;
                }
                else if (length > 1)
                {
                    Mean   mean = new Mean();
                    double m    = mean.Evaluate(values, begin, length);
                    var = Evaluate(values, m, begin, length);
                }
            }
            return(var);
        }
Exemplo n.º 5
0
 public Mean(Mean original)
 {
     Copy(original, this);
 }