Exemplo n.º 1
0
        public void BernoulliDistribution_MaximumLikelihood_FromClassifiedSample()
        {
            // arrange
            var distr  = new BernoulliDistribution();
            var sample = new ClassifiedSample <double[]>
            {
                { new[] { 1.0D, 1.0D, 0.0D }, new Class("A", 0) },
                { new[] { 1.0D, 0.0D, 1.0D }, new Class("A", 0) },
                { new[] { 0.0D, 0.0D, 1.0D }, new Class("B", 1) },
                { new[] { 0.0D, 0.0D, 0.0D }, new Class("B", 1) },
            };

            // act
            var res = distr.FromSample(sample);
            var dA1 = res[0][0];
            var dA2 = res[0][1];
            var dA3 = res[0][2];
            var dB1 = res[1][0];
            var dB2 = res[1][1];
            var dB3 = res[1][2];

            // assert
            Assert.AreEqual(1.0D, dA1.P, EPS);
            Assert.AreEqual(0.5D, dA2.P, EPS);
            Assert.AreEqual(0.5D, dA3.P, EPS);
            Assert.AreEqual(0.0D, dB1.P, EPS);
            Assert.AreEqual(0.0D, dB2.P, EPS);
            Assert.AreEqual(0.5D, dB3.P, EPS);
        }
Exemplo n.º 2
0
        protected override void EndProcessing()
        {
            var dist = new BernoulliDistribution(Mean);
            var obj  = DistributionHelper.AddConvinienceMethods(dist);

            WriteObject(obj);
        }
Exemplo n.º 3
0
        public void icdf()
        {
            // install.packages('LaplacesDemon')
            // library('LaplacesDemon')
            //
            BernoulliDistribution dist = new BernoulliDistribution(0.5);

            double[] percentiles = Vector.Range(0.0, 1.0, stepSize: 0.1);
            for (int i = 0; i < percentiles.Length; i++)
            {
                double x      = percentiles[i];
                int    icdf   = dist.InverseDistributionFunction(x);
                double cdf    = dist.DistributionFunction(icdf);
                int    iicdf  = dist.InverseDistributionFunction(cdf);
                double iiicdf = dist.DistributionFunction(iicdf);

                if (i < 6) // qbern(p=((0:10)/10), prob=0.5)
                {
                    Assert.AreEqual(0, icdf);
                }
                else
                {
                    Assert.AreEqual(1, icdf);
                }

                double rx = System.Math.Round(x, MidpointRounding.ToEven);
                double rc = System.Math.Round(cdf, MidpointRounding.ToEven);

                Assert.AreEqual(rx, rc, 1e-5);
                Assert.AreEqual(iicdf, icdf, 1e-5);
                Assert.AreEqual(iiicdf, cdf, 1e-5);
            }
        }
        public void ComplementaryDistributionFunctionTest()
        {
            BernoulliDistribution target = new BernoulliDistribution(0.42);

            {
                double expected = 1.0 - target.DistributionFunction(0);
                double actual   = target.ComplementaryDistributionFunction(0);
                Assert.AreEqual(expected, actual, 1e-6);
            }

            {
                double expected = 1.0 - target.DistributionFunction(1);
                double actual   = target.ComplementaryDistributionFunction(1);
                Assert.AreEqual(expected, actual, 1e-6);
            }

            {
                double expected = 1.0 - target.DistributionFunction(-1);
                double actual   = target.ComplementaryDistributionFunction(-1);
                Assert.AreEqual(expected, actual, 1e-6);
            }

            {
                double expected = 1.0 - target.DistributionFunction(2);
                double actual   = target.ComplementaryDistributionFunction(2);
                Assert.AreEqual(expected, actual, 1e-6);
            }
        }
        public void BernoulliDistributionFit()
        {
            double p = 0.25;

            int    n0  = 0;
            int    n1  = 0;
            Random rng = new Random(3);

            for (int i = 0; i < 100; i++)
            {
                if (rng.NextDouble() < p)
                {
                    n1++;
                }
                else
                {
                    n0++;
                }
            }
            BernoulliFitResult fit = BernoulliDistribution.FitToSample(n0, n1);

            Assert.IsTrue(fit.P.ConfidenceInterval(0.95).ClosedContains(p));
            Assert.IsTrue(fit.GoodnessOfFit.Probability > 0.05);

            Assert.IsTrue(fit.Parameters.Count == 1);
            Assert.IsTrue(fit.Parameters[0].Estimate == fit.P);
        }
Exemplo n.º 6
0
    IEnumerator run()
    {
        List <Vector2Int> points = new List <Vector2Int> {
            new Vector2Int(m_path.min.x, m_path.max.y), m_path.min, new Vector2Int(m_path.max.x, m_path.min.y), m_path.max
        };
        bool direction = new BernoulliDistribution().Next(new StaticRandomGenerator <DefaultRandomGenerator>());

        if (direction)
        {
            var temp = points[0];
            points[0] = points[3];
            points[3] = temp;
            temp      = points[2];
            points[2] = points[1];
            points[1] = temp;
        }

        int currentIndex = 0;

        while (true)
        {
            var d = (new Vector2(transform.position.x, transform.position.y) - points[currentIndex]).magnitude;

            transform.DOMove(new Vector3(points[currentIndex].x, points[currentIndex].y, transform.position.z), d / m_speed).SetEase(Ease.Linear);

            currentIndex = (currentIndex + 1) % points.Count;
            yield return(new WaitForSeconds(d / m_speed));
        }
    }
Exemplo n.º 7
0
        public void BernoulliDistribution()
        {
            Simulation.NumberOfSamples = 5;
            JsonSerializer serializer = JsonSerializer.Create(JsonSettings.SerializerSettings);

            string name = "My Distribution";

            var val = new BernoulliDistribution(0.75, 0)
            {
                Name = name
            };

            Guid guid = val.Guid;

            string json = JObject.FromObject(val, serializer).ToString();

            Simulation.ClearDistributionList();
            var newVal = JObject.Parse(json).ToObject <BernoulliDistribution>(serializer);

            Assert.AreEqual(val.Guid, newVal.Guid);
            Assert.AreEqual(val.ConstrainedToInt, newVal.ConstrainedToInt);
            Assert.AreEqual(val.RandomSeed, newVal.RandomSeed);
            Assert.AreEqual(val.Probability.ScalarValue, newVal.Probability.ScalarValue);
            Assert.AreEqual(val.Minimum, newVal.Minimum);
            Assert.AreEqual(val.Maximum, newVal.Maximum);
            Assert.AreEqual(val.Mean, newVal.Mean);
            Assert.AreEqual(val.Name, name);
        }
Exemplo n.º 8
0
        public void ConstructorTest()
        {
            var bern = new BernoulliDistribution(mean: 0.42);

            // Common measures
            double mean   = bern.Mean;     // 0.42
            double median = bern.Median;   // 0.0
            double var    = bern.Variance; // 0.2436
            double mode   = bern.Mode;     // 0.0

            // Probability mass functions
            double pdf  = bern.ProbabilityMassFunction(k: 1);    // 0.42
            double lpdf = bern.LogProbabilityMassFunction(k: 0); // -0.54472717544167193

            // Cumulative distribution function
            double cdf  = bern.DistributionFunction(k: 0);              // 0.58
            double ccdf = bern.ComplementaryDistributionFunction(k: 0); // 0.42

            // Quantile function
            int icdf0 = bern.InverseDistributionFunction(p: 0.57);    // 0
            int icdf1 = bern.InverseDistributionFunction(p: 0.59);    // 1

            double hf  = bern.HazardFunction(x: 0);                   // 1.3809523809523814
            double chf = bern.CumulativeHazardFunction(x: 0);         // 0.86750056770472328

            string str = bern.ToString(CultureInfo.InvariantCulture); // "Bernoulli(x; p = 0.42, q = 0.58)"

            Assert.AreEqual(0.42, mean);
            Assert.AreEqual(0.0, median);
            Assert.AreEqual(0.2436, var);
            Assert.AreEqual(0.0, mode);
            Assert.AreEqual(0.86750056770472328, chf, 1e-10);
            Assert.AreEqual(0.58, cdf, 1e-10);
            Assert.AreEqual(0.42, pdf);
            Assert.AreEqual(-0.54472717544167193, lpdf);
            Assert.AreEqual(1.3809523809523814, hf, 1e-10);
            Assert.AreEqual(0.42, ccdf, 1e-10);
            Assert.AreEqual(0, icdf0);
            Assert.AreEqual(1, icdf1);
            Assert.AreEqual("Bernoulli(x; p = 0.42, q = 0.58)", str);

            var range1 = bern.GetRange(0.95);
            var range2 = bern.GetRange(0.99);
            var range3 = bern.GetRange(0.01);

            Assert.AreEqual(0, range1.Min);
            Assert.AreEqual(1.0, range1.Max);
            Assert.AreEqual(0, range2.Min);
            Assert.AreEqual(1.0, range2.Max);
            Assert.AreEqual(0, range3.Min);
            Assert.AreEqual(1.0, range3.Max);


            Assert.AreEqual(0, bern.Support.Min);
            Assert.AreEqual(1, bern.Support.Max);

            Assert.AreEqual(bern.InverseDistributionFunction(0), bern.Support.Min);
            Assert.AreEqual(bern.InverseDistributionFunction(1), bern.Support.Max);
        }
Exemplo n.º 9
0
        public static BernoulliDistribution Bernoulli(double p)
        {
            var result = new BernoulliDistribution();

            result.Params = new BernoulliDistribution.Parameters(p);

            return(result);
        }
Exemplo n.º 10
0
        public void DistributionFunctionTest()
        {
            BernoulliDistribution target = new BernoulliDistribution(0.6);

            double expected = 0.4;
            double actual   = target.DistributionFunction(0);

            Assert.AreEqual(expected, actual, 1e-6);
        }
Exemplo n.º 11
0
        public void LogProbabilityMassFunctionTest()
        {
            BernoulliDistribution target = new BernoulliDistribution(0.6);

            double expected = System.Math.Log(0.6);
            double actual   = target.LogProbabilityMassFunction(1);

            Assert.AreEqual(expected, actual, 1e-6);
        }
Exemplo n.º 12
0
        public void BalancedTest()
        {
            var distribution = BernoulliDistribution.Balanced();

            Assert.AreEqual(
                expected: 0.5,
                actual: distribution.SuccessProbability,
                delta: DoubleMatrixTest.Accuracy);
        }
Exemplo n.º 13
0
        public void GenerationTest()
        {
            double prob   = 0.5;
            int    trials = 100000;

            BernoulliDistribution target = new BernoulliDistribution(prob);

            target.Fit(target.Generate(trials).Select(x => (double)x).ToArray());

            Assert.AreEqual(target.Mean, prob, 1e-2);
        }
        public void BernoulliDistribution()
        {
            Simulation.NumberOfSamples = ExpectedResults.NumberOfSamples;

            var testInfo     = ExpectedResults.Data["DistributionResults"]["BernoulliDistribution"];
            var inputs       = testInfo["ConstructorInputs"];
            var resultsArray = testInfo["Results"]
                               .Select(jv => (double)jv).ToArray();

            BernoulliDistribution distr = new BernoulliDistribution(
                inputs["probability"].Value <double>(),
                inputs["randomSeed"].Value <int>());

            Vector <double> expectedResults = Vector <double> .Build.DenseOfArray(resultsArray);

            Assert.AreEqual(expectedResults, distr.GetResult());

            distr = new BernoulliDistribution(.567);
            Assert.AreEqual(distr.Probability.ScalarValue, .567);

            bool exceptionCaught = false;

            try
            {
                distr.Probability = -1;
            }
            catch (ArgumentException)
            {
                exceptionCaught = true;
            }

            Assert.IsTrue(exceptionCaught);

            exceptionCaught = false;
            try
            {
                distr.Probability = 1.1;
            }
            catch (ArgumentException)
            {
                exceptionCaught = true;
            }

            Assert.IsTrue(exceptionCaught);

            distr.Probability = 0;
            distr.Probability = 1;

            Assert.IsTrue(distr.ConstrainedToInt);

            distr = new BernoulliDistribution();
            Assert.AreEqual(1, distr.Probability.ScalarValue);
        }
Exemplo n.º 15
0
        public void BernoulliDistribution_MaximumLikelihood_FromSample()
        {
            // arrange
            var distr  = new BernoulliDistribution();
            var sample = new[] { 1.0D, 1.0D, 0.0D, 1.0D };

            // act
            distr.FromSample(sample);
            var pars = distr.Params;

            // assert
            Assert.AreEqual(0.75D, pars.P);
        }
Exemplo n.º 16
0
        public void SuccessProbabilityTest()
        {
            // Valid successProbability
            {
                var distribution = BernoulliDistribution.Balanced();
                var expected     = 0.12;
                distribution.SuccessProbability = expected;
                Assert.AreEqual(
                    expected: expected,
                    actual: distribution.SuccessProbability,
                    delta: DoubleMatrixTest.Accuracy);
            }


            // successProbability < 0
            {
                string STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL =
                    string.Format(
                        ImplementationServices.GetResourceString(
                            "STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL"),
                        "0", "1");

                ArgumentExceptionAssert.Throw(
                    () =>
                {
                    BernoulliDistribution.Balanced().SuccessProbability = -2.0;
                },
                    expectedType: typeof(ArgumentOutOfRangeException),
                    expectedPartialMessage: STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL,
                    expectedParameterName: "value");
            }

            // successProbability > 1
            {
                string STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL =
                    string.Format(
                        ImplementationServices.GetResourceString(
                            "STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL"),
                        "0", "1");

                ArgumentExceptionAssert.Throw(
                    () =>
                {
                    BernoulliDistribution.Balanced().SuccessProbability = 2.0;
                },
                    expectedType: typeof(ArgumentOutOfRangeException),
                    expectedPartialMessage: STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL,
                    expectedParameterName: "value");
            }
        }
Exemplo n.º 17
0
        public void ConstructorTest()
        {
            // Valid input
            {
                var successProbability = 0.18;
                var distribution       = new BernoulliDistribution(
                    successProbability: successProbability);

                Assert.AreEqual(
                    expected: successProbability,
                    actual: distribution.SuccessProbability,
                    delta: DoubleMatrixTest.Accuracy);
            }

            // successProbability < 0
            {
                string STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL =
                    string.Format(
                        ImplementationServices.GetResourceString(
                            "STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL"),
                        "0", "1");

                ArgumentExceptionAssert.Throw(
                    () =>
                {
                    new BernoulliDistribution(successProbability: -2.0);
                },
                    expectedType: typeof(ArgumentOutOfRangeException),
                    expectedPartialMessage: STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL,
                    expectedParameterName: "successProbability");
            }

            // successProbability > 1
            {
                string STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL =
                    string.Format(
                        ImplementationServices.GetResourceString(
                            "STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL"),
                        "0", "1");

                ArgumentExceptionAssert.Throw(
                    () =>
                {
                    new BernoulliDistribution(successProbability: 2.0);
                },
                    expectedType: typeof(ArgumentOutOfRangeException),
                    expectedPartialMessage: STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL,
                    expectedParameterName: "successProbability");
            }
        }
Exemplo n.º 18
0
        public void BernoulliDistribution_Value()
        {
            // arrange
            var distr = new BernoulliDistribution();

            distr.Params = new BernoulliDistribution.Parameters(0.3D);

            // act
            var v0 = distr.Value(0);
            var v1 = distr.Value(1);

            // assert
            Assert.AreEqual(0.7D, v0);
            Assert.AreEqual(0.3D, v1);
        }
Exemplo n.º 19
0
    void startButtons()
    {
        float multiplier = 1 + m_currentTime / m_timeReductionDelay;
        var   gen        = new StaticRandomGenerator <DefaultRandomGenerator>();

        float multiButtonProbability = Mathf.Min(m_maxMultipleButtonChance, m_multipleButtonChance * multiplier);
        var   dMultibutton           = new BernoulliDistribution(multiButtonProbability);
        var   dButtons = new UniformIntDistribution(m_buttons.Count - 1);

        do
        {
            m_buttons[dButtons.Next(gen)].startButton(m_buttonActionTime);
        }while (dMultibutton.Next(gen));

        selectNextDelay();
    }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            Console.WriteLine("Введите вероятность p: ");
            var p = double.Parse(Console.ReadLine());

            Console.WriteLine("Введите n ");
            int n             = int.Parse(Console.ReadLine());
            var bernoulliDist = new BernoulliDistribution(p);

            string fileName = "BernoulliDist.txt";

            int count = 0;

            using (var sw = new StreamWriter(fileName))
            {
                for (double i = 1; i <= n; i++)
                {
                    double berVarible = bernoulliDist.Next();

                    if (berVarible == 1)
                    {
                        count++;
                    }

                    if (i % 10 == 0)
                    {
                        sw.WriteLine($"{i} {count / i};");
                    }
                }
            }

            //Console.WriteLine("Bernoulli dist");
            //Console.WriteLine($"Total: 1000000, Count: {count}, Count/Total: {count / 1000000}");

            //var mu = 0.5;
            //var laplaceDist = new LaplaceDistribution(alpha, mu);
            //var bigInteger = new BigInteger();

            //for (int i = 0; i < 1000000; i++)
            //{
            //    var laplaceVarible = laplaceDist.NextDouble();
            //    bigInteger += (int)laplaceVarible;
            //}

            //Console.WriteLine("Laplace dist");
            //Console.WriteLine($"Total: 1000000, Count: {bigInteger}, Count/Total: {(double)bigInteger / 1000000.0}");
        }
Exemplo n.º 21
0
 public void TestBernoulliDistribution()
 {
     double[][] para =
     {
         new double[] { 0.75, 0, 0, 0.2500000000000000000000000, 0.2500000000000000000000000 }
     };
     for (int i = 0; i < para.Length; i++)
     {
         var tester = new DiscDistTester(para[i], delegate(double a, double b)
         {
             var ret = new BernoulliDistribution
             {
                 Probability = a
             };
             return(ret);
         }
                                         );
         tester.Test(1E-14);
     }
 }
Exemplo n.º 22
0
        public void MedianTest()
        {
            {
                BernoulliDistribution target = new BernoulliDistribution(0.2);
                Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5));
            }

            {
                BernoulliDistribution target = new BernoulliDistribution(0.6);
                Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5));
            }

            {
                BernoulliDistribution target = new BernoulliDistribution(0.0);
                Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5));
            }

            {
                BernoulliDistribution target = new BernoulliDistribution(1.0);
                Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5));
            }
        }
Exemplo n.º 23
0
        public void MedianTest()
        {
            {
                // Special case for the Bernoulli distribution: while the median is 0.5,
                // the inverse distribution function cannot return a double value and thus
                // returns 1.
                BernoulliDistribution target = new BernoulliDistribution(0.5);
                int icdf = target.InverseDistributionFunction(0.5);
                Assert.AreEqual(0, icdf);
                Assert.AreEqual(0.5, target.Median);

                // However, it should work if the Bernoulli is being used as a continuous distribution:
                Assert.AreEqual(0.5, (target as IUnivariateDistribution).InverseDistributionFunction(0.5));
                Assert.AreEqual(0.5, (target as IUnivariateDistribution <double>).InverseDistributionFunction(0.5));
            }

            {
                BernoulliDistribution target = new BernoulliDistribution(0.2);
                Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5));
            }

            {
                BernoulliDistribution target = new BernoulliDistribution(0.6);
                Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5));
            }

            {
                BernoulliDistribution target = new BernoulliDistribution(0.0);
                Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5));
            }

            {
                BernoulliDistribution target = new BernoulliDistribution(1.0);
                Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5));
            }
        }
Exemplo n.º 24
0
    void spawn()
    {
        GameObject objectToSpawn = m_redBall;

        if (m_spawnedPink == null)
        {
            objectToSpawn = m_pinkBall;
        }
        if (m_spawnedGreen == null)
        {
            objectToSpawn = m_greenBall;
        }
        if (m_spawnedBlue == null)
        {
            objectToSpawn = m_blueBall;
        }

        float redProbability = m_totalSpawnCount > m_spawnLimit ? m_redProbability : m_redProbability * ((float)m_totalSpawnCount / m_spawnLimit);

        if (m_spawnedPink != null && m_spawnedGreen != null && m_spawnedBlue != null)
        {
            redProbability = m_redProbability;
        }

        bool toRed = new BernoulliDistribution(redProbability).Next(new StaticRandomGenerator <DefaultRandomGenerator>());

        if (objectToSpawn == m_redBall && !toRed)
        {
            m_timer = m_spawnTime;
            return;
        }
        if (objectToSpawn != m_redBall && toRed)
        {
            objectToSpawn = m_redBall;
        }

        m_spawning = true;
        DOVirtual.DelayedCall(m_spawnDelay, () =>
        {
            var obj  = Instantiate(objectToSpawn, new Vector3(transform.position.x, m_spawnHeight, -0.5f), Quaternion.identity);
            var comp = obj.GetComponent <BallLogic>();
            if (comp != null)
            {
                comp.setPath(m_possiblePath[new UniformIntDistribution(m_possiblePath.Count - 1).Next(new StaticRandomGenerator <DefaultRandomGenerator>())]);
            }

            if (objectToSpawn == m_pinkBall)
            {
                m_spawnedPink = obj;
            }
            if (objectToSpawn == m_greenBall)
            {
                m_spawnedGreen = obj;
            }
            if (objectToSpawn == m_blueBall)
            {
                m_spawnedBlue = obj;
            }

            m_timer = m_spawnTime;
            m_totalSpawnCount++;

            DOVirtual.DelayedCall(m_spawnDelay, () => m_spawning = false);
        });
    }
Exemplo n.º 25
0
        public ValueType Sample()
        {
            var bernoulli = new BernoulliDistribution(_probability);

            return(bernoulli.Sample(rand));
        }
Exemplo n.º 26
0
    /// <summary>
    /// Sets the distribution for operations using the current genrator
    /// </summary>
    /// <param name="distx">Distx.</param>
    public void setDistribution(distributions distx, Dictionary <string, double> args)
    {
        //TODO check arguments to ensure they are making a change to the distribution
        //otherwise throw an exception see laplace as a example of implementing this
        switch (distx)
        {
        case distributions.Bernoili:
            BernoulliDistribution x0 = new BernoulliDistribution(gen);
            if (args.ContainsKey("alpha"))
            {
                x0.Alpha = args["alpha"];
            }
            else
            {
                throw new System.Exception("for Bernoili distribution you must provide an alpha");
            }
            dist = x0;
            break;

        case distributions.Beta:
            BetaDistribution x1 = new BetaDistribution(gen);
            if (args.ContainsKey("alpha") && args.ContainsKey("beta"))
            {
                x1.Alpha = args["alpha"];
                x1.Beta  = args["beta"];
            }
            else
            {
                throw new System.Exception(" for beta distribution you must provide alpha and beta");
            }
            dist = x1;
            break;

        case distributions.BetaPrime:
            BetaPrimeDistribution x2 = new BetaPrimeDistribution(gen);
            if (args.ContainsKey("alpha") && args.ContainsKey("beta"))
            {
                x2.Alpha = args["alpha"];
                x2.Beta  = args["beta"];
            }
            else
            {
                throw new System.Exception(" for betaPrime distribution you must provide alpha and beta");
            }
            dist = x2;
            break;

        case distributions.Cauchy:
            CauchyDistribution x3 = new CauchyDistribution(gen);
            if (args.ContainsKey("alpha") && args.ContainsKey("gamma"))
            {
                x3.Alpha = args["alpha"];
                x3.Gamma = args["gamma"];
            }
            else
            {
                throw new System.Exception("for cauchy dist you must provide alpha and gamma");
            }
            dist = x3;
            break;

        case distributions.Chi:
            ChiDistribution x4 = new ChiDistribution(gen);
            if (args.ContainsKey("alpha"))
            {
                x4.Alpha = (int)args["alpha"];
            }
            else
            {
                throw new System.Exception("for chi you must provide alpha");
            }
            dist = x4;
            break;

        case distributions.ChiSquared:
            ChiSquareDistribution x5 = new ChiSquareDistribution(gen);
            if (args.ContainsKey("alpha"))
            {
                x5.Alpha = (int)args["alpha"];
            }
            else
            {
                throw new System.Exception("for chiSquared you must provide alpha");
            }
            dist = x5;
            break;

        case distributions.ContinuousUniform:
            ContinuousUniformDistribution x6 = new ContinuousUniformDistribution(gen);
            if (args.ContainsKey("alpha") && args.ContainsKey("beta"))
            {
                x6.Alpha = args["alpha"];
                x6.Beta  = args["beta"];
            }
            else
            {
                throw new System.Exception("for ContinuousUniform you must provide alpha and beta");
            }
            dist = x6;
            break;

        case distributions.DiscreteUniform:
            DiscreteUniformDistribution x7 = new DiscreteUniformDistribution(gen);
            if (args.ContainsKey("alpha") && args.ContainsKey("beta"))
            {
                x7.Alpha = (int)args["alpha"];
                x7.Beta  = (int)args["beta"];
            }
            else
            {
                throw new System.Exception("for discrete uniform distribution you must provide alpha and beta");
            }
            dist = x7;
            break;

        case distributions.Erlang:
            ErlangDistribution x8 = new ErlangDistribution(gen);
            if (args.ContainsKey("alpha") && args.ContainsKey("lambda"))
            {
                x8.Alpha  = (int)args["alpha"];
                x8.Lambda = (int)args["lambda"];
            }
            else
            {
                throw new System.Exception("for Erlang dist you must provide alpha and lambda");
            }
            dist = x8;
            break;

        case distributions.Exponential:
            ExponentialDistribution x9 = new ExponentialDistribution(gen);
            if (args.ContainsKey("lambda"))
            {
                x9.Lambda = args["lambda"];
            }
            else
            {
                throw new System.Exception("for exponential dist you must provide lambda");
            }
            dist = x9;
            break;

        case distributions.FisherSnedecor:
            FisherSnedecorDistribution x10 = new FisherSnedecorDistribution(gen);
            if (args.ContainsKey("alpha") && args.ContainsKey("beta"))
            {
                x10.Alpha = (int)args["alpha"];
                x10.Beta  = (int)args["beta"];
            }
            else
            {
                throw new System.Exception("for FisherSnedecor you must provide alpha and beta");
            }
            dist = x10;
            break;

        case distributions.FisherTippett:
            FisherTippettDistribution x11 = new FisherTippettDistribution(gen);
            if (args.ContainsKey("alpha") && args.ContainsKey("mu"))
            {
                x11.Alpha = args["alpha"];
                x11.Mu    = args["mu"];
            }
            else
            {
                throw new System.Exception("for FisherTippets you must provide alpha and mu");
            }
            dist = x11;
            break;

        case distributions.Gamma:
            GammaDistribution x12 = new GammaDistribution(gen);
            if (args.ContainsKey("alpha") && args.ContainsKey("theta"))
            {
                x12.Alpha = args["alpha"];
                x12.Theta = args["theta"];
            }
            else
            {
                throw new System.Exception("for Gamma dist you must provide alpha and theta");
            }
            dist = x12;
            break;

        case distributions.Geometric:
            GeometricDistribution x13 = new GeometricDistribution(gen);
            if (args.ContainsKey("alpha"))
            {
                x13.Alpha = args["alpha"];
            }
            else
            {
                throw new System.Exception("Geometric distribution requires alpha value");
            }
            dist = x13;
            break;

        case distributions.Binomial:
            BinomialDistribution x14 = new BinomialDistribution(gen);
            if (args.ContainsKey("alpha") && args.ContainsKey("beta"))
            {
                x14.Alpha = args["alpha"];
                x14.Beta  = (int)args["beta"];
            }
            else
            {
                throw new System.Exception("binomial distribution requires alpha and beta");
            }
            dist = x14;
            break;

        case distributions.None:
            break;

        case distributions.Laplace:
            LaplaceDistribution x15 = new LaplaceDistribution(gen);
            if (args.ContainsKey("alpha") && args.ContainsKey("mu"))
            {
                if (x15.IsValidAlpha(args["alpha"]) && x15.IsValidMu(args["mu"]))
                {
                    x15.Alpha = args["alpha"];
                    x15.Mu    = args["mu"];
                }
                else
                {
                    throw new ArgumentException("alpha must be greater than zero");
                }
            }
            else
            {
                throw new System.Exception("Laplace dist requires alpha and mu");
            }
            dist = x15;
            break;

        case distributions.LogNormal:
            LognormalDistribution x16 = new LognormalDistribution(gen);
            if (args.ContainsKey("mu") && args.ContainsKey("sigma"))
            {
                x16.Mu    = args["mu"];
                x16.Sigma = args["sigma"];
            }
            else
            {
                throw new System.Exception("lognormal distribution requires mu and sigma");
            }
            dist = x16;
            break;

        case distributions.Normal:
            NormalDistribution x17 = new NormalDistribution(gen);
            if (args.ContainsKey("mu") && args.ContainsKey("sigma"))
            {
                x17.Mu    = args["mu"];
                x17.Sigma = args["sigma"];
            }
            else
            {
                throw new System.Exception("normal distribution requires mu and sigma");
            }
            dist = x17;
            break;

        case distributions.Pareto:
            ParetoDistribution x18 = new ParetoDistribution(gen);
            if (args.ContainsKey("alpha") && args.ContainsKey("beta"))
            {
                x18.Alpha = args["alpha"];
                x18.Beta  = args["beta"];
            }
            else
            {
                throw new System.Exception("pareto distribution requires alpha and beta");
            }
            dist = x18;
            break;

        case distributions.Poisson:
            PoissonDistribution x19 = new PoissonDistribution(gen);
            if (args.ContainsKey("lambda"))
            {
                x19.Lambda = args["lambda"];
            }
            else
            {
                throw new System.Exception("Poisson distribution requires lambda");
            }
            dist = x19;
            break;

        case distributions.Power:
            PowerDistribution x20 = new PowerDistribution(gen);
            if (args.ContainsKey("alpha") && args.ContainsKey("beta"))
            {
                x20.Alpha = args["alpha"];
                x20.Beta  = args["beta"];
            }
            else
            {
                throw new System.Exception("Power dist requires alpha and beta");
            }
            dist = x20;
            break;

        case distributions.RayLeigh:
            RayleighDistribution x21 = new RayleighDistribution(gen);
            if (args.ContainsKey("sigma"))
            {
                x21.Sigma = args["sigma"];
            }
            else
            {
                throw new System.Exception("Rayleigh dist requires sigma");
            }
            dist = x21;
            break;

        case distributions.StudentsT:
            StudentsTDistribution x22 = new StudentsTDistribution(gen);
            if (args.ContainsKey("nu"))
            {
                x22.Nu = (int)args["nu"];
            }
            else
            {
                throw new System.Exception("StudentsT dist requirres nu");
            }
            dist = x22;
            break;

        case distributions.Triangular:
            TriangularDistribution x23 = new TriangularDistribution(gen);
            if (args.ContainsKey("alpha") && args.ContainsKey("beta") && args.ContainsKey("gamma"))
            {
                x23.Alpha = args["alpha"];
                x23.Beta  = args["beta"];
                x23.Gamma = args["gamma"];
            }
            else
            {
                throw new System.Exception("Triangular distribution requires alpha, beta and gamma");
            }
            dist = x23;
            break;

        case distributions.WeiBull:
            WeibullDistribution x24 = new WeibullDistribution(gen);
            if (args.ContainsKey("alpha") && args.ContainsKey("lambda"))
            {
                x24.Alpha  = args["alpha"];
                x24.Lambda = args["lambda"];
            }
            else
            {
                throw new System.Exception("WeiBull dist requires alpha and lambda");
            }
            dist = x24;
            break;

        default:
            throw new NotImplementedException("the distribution you want has not yet been implemented " +
                                              "you could help everyone out by going and implementing it");
        }
    }