public void Probability_Simple_Test()
        {
            var Inputs = InputBuilder.CreateInputs(MinInputs, MaxInputs, MinWeight, MaxWeight);
            var Selector = new WeightedSelector<string>();
            Selector.Add(Inputs);

            var Helper = new ProbabilityHelpers(Selector, Inputs, Trials, AcceptableDeviation);


            Console.WriteLine("Running {0} trials with {1} items (total weight: {2})", 
                              Trials,
                              Selector.ReadOnlyItems.Count,
                              Selector.TotalWeight());

            var ResultCounter = Helper.RunTrialsAndCountResults();

            foreach (var Key in ResultCounter.Keys)
                Helper.ExamineMetricsForKey(Key);

            Assert.IsTrue(ResultCounter.Keys.Count == Inputs.Count,
                          string.Format("Expected {0} outputs, actual: {1}. Details: {2}", 
                                        Inputs.Count,                                                                                  
                                        ResultCounter.Keys.Count,                                                                                         
                                        Helper.GetErrorMessage()));
        } 
Esempio n. 2
0
        public void Probability_Simple_Test()
        {
            var Inputs   = InputBuilder.CreateInputs(MinInputs, MaxInputs, MinWeight, MaxWeight);
            var Selector = new WeightedSelector <string>();

            Selector.Add(Inputs);

            var Helper = new ProbabilityHelpers(Selector, Inputs, Trials, AcceptableDeviation);


            Console.WriteLine("Running {0} trials with {1} items (total weight: {2})",
                              Trials,
                              Selector.ReadOnlyItems.Count,
                              Selector.TotalWeight());

            var ResultCounter = Helper.RunTrialsAndCountResults();

            foreach (var Key in ResultCounter.Keys)
            {
                Helper.ExamineMetricsForKey(Key);
            }

            Assert.IsTrue(ResultCounter.Keys.Count == Inputs.Count,
                          string.Format("Expected {0} outputs, actual: {1}. Details: {2}",
                                        Inputs.Count,
                                        ResultCounter.Keys.Count,
                                        Helper.GetErrorMessage()));
        }
Esempio n. 3
0
        public void Probability_ExtremeInputs_Test()
        {
            var Inputs   = InputBuilder.CreateInputs(MinInputs, MaxInputs, MinWeight, MaxWeight);
            var Selector = new WeightedSelector <string>();

            Selector.Add(Inputs);

            var Helper = new ProbabilityHelpers(Selector, Inputs, Trials, AcceptableDeviation);

            Console.WriteLine("Running {0} trials with {1} items (total weight: {2})",
                              Trials,
                              Selector.ReadOnlyItems.Count,
                              Selector.TotalWeight());

            var ResultCounter = Helper.RunTrialsAndCountResults();

            foreach (var Key in ResultCounter.Keys)
            {
                Helper.ExamineMetricsForKey(Key);
            }

            //Note that in this test, a ton of items will never be selected because there are so many.
            //If we did tens of millions of trials that would counter it, but it might take 30s+, which is
            //unecessary.
            Console.WriteLine("Expected {0} outputs, actual: {1}. Details: {2}",
                              Inputs.Count,
                              ResultCounter.Keys.Count,
                              Helper.GetErrorMessage());
        }
        public void Probability_ExtremeInputs_Test()
        {
            var Inputs = InputBuilder.CreateInputs(MinInputs, MaxInputs, MinWeight, MaxWeight);
            var Selector = new WeightedSelector<string>();
            Selector.Add(Inputs);

            var Helper = new ProbabilityHelpers(Selector, Inputs, Trials, AcceptableDeviation);

            Console.WriteLine("Running {0} trials with {1} items (total weight: {2})", 
                              Trials,
                              Selector.ReadOnlyItems.Count,
                              Selector.TotalWeight());

            var ResultCounter = Helper.RunTrialsAndCountResults();

            foreach (var Key in ResultCounter.Keys)
                Helper.ExamineMetricsForKey(Key);

            //Note that in this test, a ton of items will never be selected because there are so many.
            //If we did tens of millions of trials that would counter it, but it might take 30s+, which is 
            //unecessary.
            Console.WriteLine("Expected {0} outputs, actual: {1}. Details: {2}",
                              Inputs.Count,                                                                                  
                              ResultCounter.Keys.Count,                                                                                         
                              Helper.GetErrorMessage());
        } 
Esempio n. 5
0
        private decimal GetSelectionProportion(string key)
        {
            //Over all of our tests, how many times did we select this key?
            var Total = Selector.TotalWeight();

            var Item = (from WeightedItem <string> W in Selector.ReadOnlyItems
                        where W.Value == key
                        select W).First();

            return(((decimal)Item.Weight / Total) * 100);
        }