private void Test_10K_Tries(double[] probabilties, double[] resultsToCheck)
        {
            var       generator = new AliasMethodGenerator(probabilties, CreateRealRandom());
            const int attempts  = 200000;
            var       results   = new List <int>();

            for (var i = 0; i < attempts; i++)
            {
                results.Add(generator.GetValue());
            }
            var grouped = results.GroupBy(i => i).ToDictionary(key => key.Key, value => (double)value.Count());

            for (var i = 0; i < resultsToCheck.Length; i++)
            {
                if (grouped.ContainsKey(i))
                {
                    var roundedProbability = System.Math.Round(grouped[i] / attempts, 2);
                    Assert.AreEqual(roundedProbability, resultsToCheck[i]);
                }
                else
                {
                    Assert.AreEqual(0, resultsToCheck[i]);
                }
            }
        }
        public void Should_Generate_0_Value()
        {
            var random = CreateRandomMock(new List <Tuple <int, int> >()
            {
                Tuple.Create(2, 0), Tuple.Create(3, 0)
            });
            var generator = new AliasMethodGenerator(new double[] { 1, 2 }, random);

            Assert.AreEqual(0, generator.GetValue());
        }
        public void Should_Return_Correct_Value_If_Only_Item()
        {
            var generator = new AliasMethodGenerator(new double[] { 1 }, CreateRealRandom());

            Assert.AreEqual(0, generator.GetValue());
        }