Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            DiceDist test = 10 * new DiceDist(10) + new DiceDist(10) - 10;

            Console.WriteLine(test);
            Console.WriteLine($"Expected Value = {test.ExpectedValue}");
            Console.WriteLine($"Variance = {test.Variance}");
            Console.WriteLine($"Standard Deviation = {test.StdDeviance}");

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public static DiceDist NumDivWithRounding(DiceDist d, int q, RoundingType rounding)
        {
            var dD = new Dictionary <int, int>();

            foreach (var kvp in d._distributionDividends)
            {
                var newKey = Round((double)kvp.Key / q, rounding);
                if (dD.ContainsKey(newKey))
                {
                    dD[newKey] += kvp.Value;
                }
                else
                {
                    dD.Add(newKey, kvp.Value);
                }
            }

            return(new DiceDist(dD, d._divisor));
        }
Ejemplo n.º 3
0
        public static DiceDist DiceDiv(DiceDist a, DiceDist b, RoundingType rounding)
        {
            var dD = new Dictionary <int, int>();

            foreach (var kvpa in a._distributionDividends)
            {
                foreach (var kvpb in b._distributionDividends)
                {
                    var newKey = Round((double)kvpa.Key / kvpb.Key, rounding);
                    if (dD.ContainsKey(newKey))
                    {
                        // a and b are assumed independent, note divisors also multiplied
                        dD[newKey] += kvpa.Value * kvpb.Value;
                    }
                    else
                    {
                        dD.Add(newKey, kvpa.Value * kvpb.Value);
                    }
                }
            }

            return(new DiceDist(dD, a._divisor * b._divisor));
        }