public void Add_AddToVectorCorrectVector()
        {
            Vector vector = new Vector(new double[] { 1.0, 2.0, 3.0});
            Vector vector2 = new Vector(new double[] { 2.0, 3.0, 4.0 });

            vector.Add(vector2);

            Assert.AreEqual(vector.Values[0], 3.0);
            Assert.AreEqual(vector.Values[1], 5.0);
            Assert.AreEqual(vector.Values[2], 7.0);
        }
Exemple #2
0
        public static Vector GetMeanOfVectors(List<Vector> vectors)
        {
            Vector result = new Vector(vectors[0].values.Length, 0.0);

            foreach (Vector item in vectors)
            {
                result.Add(item);
            }

            result.Divide((double)vectors.Count);

            return result;
        }
Exemple #3
0
        public static Vector GetYMeanOfSamples(List<Sample> samples)
        {
            int count = samples.Count;

            Vector result = new Vector(Params.inputDataDimension, 0.0);

            foreach (Sample sample in samples)
            {
                result.Add(sample.Y);
            }

            result.Divide(count);

            return result;
        }
Exemple #4
0
        public static Vector GetXMeanOfSamples(List<Sample> samples)
        {
            if (samples.Count == 0) throw new InvalidOperationException("impossible to return mean from 0 samples");

            int count = samples.Count;

            Vector result = new Vector(Params.inputDataDimension, 0.0);
            foreach (Sample sample in samples)
            {
                result.Add(sample.X);
            }

            result.Divide(count);
            return result;
        }