예제 #1
0
        public void WeightedSel()
        {
            List <int> choices = new List <int> {
                1, 2, 3, 4
            };

            var choice_chooser = new WeightedSelector <int>(choices.Select(c => Tuple.Create(c, c * 1.0)));

            Random rando = new Random();

            List <int> outputs = new List <int>();

            for (int i = 0; i < 10000; i++)
            {
                outputs.Add(choice_chooser.PickRandom(rando));
            }

            var groups = string.Join("|", outputs.GroupBy(c => c).Select((c, d) => c.Key + " " + c.Count()));
        }