Exemplo n.º 1
0
 /// <summary>Makes.</summary>
 /// <param name="label">The label.</param>
 /// <param name="x">The Range to process.</param>
 /// <param name="count">(Optional) number of.</param>
 /// <returns>A Statistic.</returns>
 public static Statistic Make(string label, Range x, int count = 0)
 {
     return new Statistic
     {
         Label = label,
         Discrete = false,
         Count = count,
         X = x
     };
 }
Exemplo n.º 2
0
        public void Test_Enumerable_Segmentation_2()
        {
            Vector x = new[] { 1d, 2, 3, 4, 5, 6, 7, 8, 9 };
            var ranges = x.Segment(2);
            var truth = new Range[]
            {
                Range.Make(1, 5),
                Range.Make(5, 9.01),
            };

            Assert.AreEqual(truth.Length, ranges.Length);
            for (int i = 0; i < truth.Length; i++)
            {
                Assert.AreEqual(truth[i].Min, ranges[i].Min);
                Assert.AreEqual(truth[i].Max, ranges[i].Max);
            }
        }
Exemplo n.º 3
0
        public void Test_Enumerable_Segmentation_4()
        {
            Vector x = new[] { 1d, 2, 3, 4, 5, 6, 7, 8, 9 };
            var ranges = x.Segment(4);
            var segmentsize = 8d / 4d;
            var truth = new Range[] 
            {
                Range.Make(1, 1 + segmentsize),
                Range.Make(1 + segmentsize, 1 + 2 * segmentsize),
                Range.Make(1 + 2 * segmentsize, 1 + 3 * segmentsize),
                Range.Make( 1 + 3 * segmentsize, 9.01)
            };

            Assert.AreEqual(truth.Length, ranges.Length);
            for (int i = 0; i < truth.Length; i++)
            {
                Assert.AreEqual(truth[i].Min, ranges[i].Min);
                Assert.AreEqual(truth[i].Max, ranges[i].Max);
            }
        }