Example #1
0
        public void should_return_percentiles_for_given_data(Expectation expectation)
        {
            var builder = new LinearInterpolationBuilder(expectation.DesiredPercentiles);

            foreach (var datum in expectation.Values.Shuffle().ToArray())
            {
                builder.AddValue(datum);
            }

            var percentiles = builder.GetPercentiles().ToList();

            percentiles.ShouldBeEquivalentTo(expectation.ExpectedPercentiles, true);
        }
Example #2
0
        public void should_work_with_random_uniform_distribution()
        {
            var random  = new Random();
            var builder = new LinearInterpolationBuilder();

            for (var i = 0; i < 1000000; ++i)
            {
                builder.AddValue(random.NextDouble() * 100);
            }

            var percentiles = builder.GetPercentiles().ToList();

            Console.WriteLine(string.Join(", ", percentiles));
            for (var i = 0; i < 9; ++i)
            {
                var deltaToPercentile = percentiles[i].Value - ((i + 1) * 10);
                deltaToPercentile.ShouldBeLessThan(0.15);
            }
        }