public void MultivariateLinearLogisticRegressionSimple()
        {
            // define model y = a + b0 * x0 + b1 * x1 + noise
            double a  = 1.0;
            double b0 = -1.0 / 2.0;
            double b1 = 1.0 / 3.0;
            ContinuousDistribution x0distribution = new LaplaceDistribution();
            ContinuousDistribution x1distribution = new NormalDistribution();

            // draw a sample from the model
            Random             rng   = new Random(1);
            MultivariateSample old   = new MultivariateSample("y", "x0", "x1");
            FrameTable         table = new FrameTable();

            table.AddColumn <double>("x0");
            table.AddColumn <double>("x1");
            table.AddColumn <bool>("y");

            for (int i = 0; i < 100; i++)
            {
                double x0 = x0distribution.GetRandomValue(rng);
                double x1 = x1distribution.GetRandomValue(rng);
                double t  = a + b0 * x0 + b1 * x1;
                double p  = 1.0 / (1.0 + Math.Exp(-t));
                bool   y  = (rng.NextDouble() < p);
                old.Add(y ? 1.0 : 0.0, x0, x1);
                table.AddRow(x0, x1, y);
            }

            // do a linear regression fit on the model
            MultiLinearLogisticRegressionResult oldResult = old.LogisticLinearRegression(0);
            MultiLinearLogisticRegressionResult newResult = table["y"].As <bool>().MultiLinearLogisticRegression(
                table["x0"].As <double>(), table["x1"].As <double>()
                );

            // the result should have the appropriate dimension
            Assert.IsTrue(newResult.Parameters.Count == 3);

            // The parameters should match the model
            Assert.IsTrue(newResult.CoefficientOf(0).ConfidenceInterval(0.99).ClosedContains(b0));
            Assert.IsTrue(newResult.CoefficientOf("x1").ConfidenceInterval(0.99).ClosedContains(b1));
            Assert.IsTrue(newResult.Intercept.ConfidenceInterval(0.99).ClosedContains(a));

            // Our predictions should be better than chance.
            int correct = 0;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                FrameRow row = table.Rows[i];
                double   x0  = (double)row["x0"];
                double   x1  = (double)row["x1"];
                double   p   = newResult.Predict(x0, x1).Value;
                bool     y   = (bool)row["y"];
                if ((y && p > 0.5) || (!y & p < 0.5))
                {
                    correct++;
                }
            }
            Assert.IsTrue(correct > 0.5 * table.Rows.Count);
        }
Exemple #2
0
        public void ConstructorTest2()
        {
            var laplace = new LaplaceDistribution(location: 4, scale: 2);

            double mean   = laplace.Mean;                                     // 4.0
            double median = laplace.Median;                                   // 4.0
            double var    = laplace.Variance;                                 // 8.0

            double cdf  = laplace.DistributionFunction(x: 0.27);              // 0.077448104942453522
            double pdf  = laplace.ProbabilityDensityFunction(x: 0.27);        // 0.038724052471226761
            double lpdf = laplace.LogProbabilityDensityFunction(x: 0.27);     // -3.2512943611198906

            double ccdf = laplace.ComplementaryDistributionFunction(x: 0.27); // 0.92255189505754642
            double icdf = laplace.InverseDistributionFunction(p: cdf);        // 0.27

            double hf  = laplace.HazardFunction(x: 0.27);                     // 0.041974931360160776
            double chf = laplace.CumulativeHazardFunction(x: 0.27);           // 0.080611649844768624

            string str = laplace.ToString(CultureInfo.InvariantCulture);      // Laplace(x; μ = 4, b = 2)

            Assert.AreEqual(4.0, mean);
            Assert.AreEqual(4.0, median);
            Assert.AreEqual(8.0, var);
            Assert.AreEqual(0.080611649844768624, chf);
            Assert.AreEqual(0.077448104942453522, cdf);
            Assert.AreEqual(0.038724052471226761, pdf);
            Assert.AreEqual(-3.2512943611198906, lpdf);
            Assert.AreEqual(0.041974931360160776, hf);
            Assert.AreEqual(0.92255189505754642, ccdf);
            Assert.AreEqual(0.26999999840794775, icdf);
            Assert.AreEqual("Laplace(x; μ = 4, b = 2)", str);
        }
        public void MultivariateLinearRegressionVariances()
        {
            // define model y = a + b0 * x0 + b1 * x1 + noise
            double a  = -3.0;
            double b0 = 2.0;
            double b1 = -1.0;
            ContinuousDistribution x0distribution = new LaplaceDistribution();
            ContinuousDistribution x1distribution = new CauchyDistribution();
            ContinuousDistribution eDistribution  = new NormalDistribution(0.0, 4.0);

            FrameTable data = new FrameTable();

            data.AddColumns <double>("a", "da", "b0", "db0", "b1", "db1", "ab1Cov", "p", "dp");

            // draw a sample from the model
            Random rng = new Random(4);

            for (int j = 0; j < 64; j++)
            {
                List <double> x0s = new List <double>();
                List <double> x1s = new List <double>();
                List <double> ys  = new List <double>();

                for (int i = 0; i < 16; i++)
                {
                    double x0 = x0distribution.GetRandomValue(rng);
                    double x1 = x1distribution.GetRandomValue(rng);
                    double e  = eDistribution.GetRandomValue(rng);
                    double y  = a + b0 * x0 + b1 * x1 + e;
                    x0s.Add(x0);
                    x1s.Add(x1);
                    ys.Add(y);
                }

                // do a linear regression fit on the model
                MultiLinearRegressionResult result = ys.MultiLinearRegression(
                    new Dictionary <string, IReadOnlyList <double> > {
                    { "x0", x0s }, { "x1", x1s }
                }
                    );
                UncertainValue pp = result.Predict(-5.0, 6.0);

                data.AddRow(
                    result.Intercept.Value, result.Intercept.Uncertainty,
                    result.CoefficientOf("x0").Value, result.CoefficientOf("x0").Uncertainty,
                    result.CoefficientOf("x1").Value, result.CoefficientOf("x1").Uncertainty,
                    result.Parameters.CovarianceOf("Intercept", "x1"),
                    pp.Value, pp.Uncertainty
                    );
            }

            // The estimated parameters should agree with the model that generated the data.

            // The variances of the estimates should agree with the claimed variances
            Assert.IsTrue(data["a"].As <double>().PopulationStandardDeviation().ConfidenceInterval(0.99).ClosedContains(data["da"].As <double>().Mean()));
            Assert.IsTrue(data["b0"].As <double>().PopulationStandardDeviation().ConfidenceInterval(0.99).ClosedContains(data["db0"].As <double>().Mean()));
            Assert.IsTrue(data["b1"].As <double>().PopulationStandardDeviation().ConfidenceInterval(0.99).ClosedContains(data["db1"].As <double>().Mean()));
            Assert.IsTrue(data["a"].As <double>().PopulationCovariance(data["b1"].As <double>()).ConfidenceInterval(0.99).ClosedContains(data["ab1Cov"].As <double>().Mean()));
            Assert.IsTrue(data["p"].As <double>().PopulationStandardDeviation().ConfidenceInterval(0.99).ClosedContains(data["dp"].As <double>().Median()));
        }
        public void LaplaceTest()
        {
            var target = GeneralizedNormalDistribution.Laplace(location: 0.42, scale: 4.2);
            var normal = new LaplaceDistribution(location: 0.42, scale: 4.2);

            test(target, normal);
        }
        public void LaplaceDistributionConstructorTest()
        {
            {
                LaplaceDistribution target = new LaplaceDistribution(0, 0.2);

                double[] expected = { 2.5, 1.5163266, 0.919699, 0.557825, 0.338338 };

                for (int i = 0; i < expected.Length; i++)
                {
                    double x      = i / 10.0;
                    double actual = target.ProbabilityDensityFunction(x);
                    Assert.AreEqual(expected[i], actual, 1e-6);
                    Assert.IsFalse(double.IsNaN(actual));
                }
            }

            {
                LaplaceDistribution target = new LaplaceDistribution(-2, 5.79);

                double[] expected = { 0.0666469, 0.0655057, 0.06438406, 0.0632816234, 0.062198060, 0.061133051 };

                for (int i = 0; i < expected.Length; i++)
                {
                    double x      = (i - 5) / 10.0;
                    double actual = target.ProbabilityDensityFunction(x);
                    Assert.AreEqual(expected[i], actual, 1e-8);
                    Assert.IsFalse(double.IsNaN(actual));
                }
            }
        }
Exemple #6
0
        //End of ui.cs file Contents

        //-------------------------------------------------------------------------

        //Begin of Random.cs file contents
        /// <summary>
        /// Initializes the random-number generator with a specific seed.
        /// </summary>
        public void Initialize(uint seed)
        {
            RandomNumberGenerator = new MT19937Generator(seed);
            betaDist              = new BetaDistribution(RandomNumberGenerator);
            betaPrimeDist         = new BetaPrimeDistribution(RandomNumberGenerator);
            cauchyDist            = new CauchyDistribution(RandomNumberGenerator);
            chiDist               = new ChiDistribution(RandomNumberGenerator);
            chiSquareDist         = new ChiSquareDistribution(RandomNumberGenerator);
            continuousUniformDist = new ContinuousUniformDistribution(RandomNumberGenerator);
            erlangDist            = new ErlangDistribution(RandomNumberGenerator);
            exponentialDist       = new ExponentialDistribution(RandomNumberGenerator);
            fisherSnedecorDist    = new FisherSnedecorDistribution(RandomNumberGenerator);
            fisherTippettDist     = new FisherTippettDistribution(RandomNumberGenerator);
            gammaDist             = new GammaDistribution(RandomNumberGenerator);
            laplaceDist           = new LaplaceDistribution(RandomNumberGenerator);
            lognormalDist         = new LognormalDistribution(RandomNumberGenerator);
            normalDist            = new NormalDistribution(RandomNumberGenerator);
            paretoDist            = new ParetoDistribution(RandomNumberGenerator);
            powerDist             = new PowerDistribution(RandomNumberGenerator);
            rayleighDist          = new RayleighDistribution(RandomNumberGenerator);
            studentsTDist         = new StudentsTDistribution(RandomNumberGenerator);
            triangularDist        = new TriangularDistribution(RandomNumberGenerator);
            weibullDist           = new WeibullDistribution(RandomNumberGenerator);
            poissonDist           = new PoissonDistribution(RandomNumberGenerator);

            // generator.randomGenerator = new MT19937Generator(seed);
        }
        public PositionSet3D getRandomPositionSet(int pointNum)
        {
            unchecked
            {
                int seed = (int)DateTime.Now.Ticks;
                this.pointNum = pointNum;
                LaplaceDistribution distributionX = new LaplaceDistribution(new StandardGenerator(seed++));
                distributionX.Alpha = X_Alpha;

                LaplaceDistribution distributionY = new LaplaceDistribution(new StandardGenerator(seed++));
                distributionY.Alpha = Y_Alpha;

                LaplaceDistribution distributionZ = new LaplaceDistribution(new StandardGenerator(seed++));
                distributionZ.Alpha = Z_Alpha;

                Random r = new Random();
                for (int i = 0; i < clusterPointNum; i++)
                {
                    distributionX.Mu = minMu + (float)(r.NextDouble() * (maxMu - minMu));
                    distributionY.Mu = minMu + (float)(r.NextDouble() * (maxMu - minMu));
                    distributionZ.Mu = minMu + (float)(r.NextDouble() * (maxMu - minMu));
                    RandomPositionSet3D randomPositionSet =
                        new RandomPositionSet3D((int)(pointNum / clusterPointNum), scale, distributionX, distributionY, distributionZ);
                    positionSet3D = (PositionSet3D)randomPositionSet;
                }
            }
            return(positionSet3D);
        }
Exemple #8
0
        public void ConstructorTest7()
        {
            var original = new LaplaceDistribution(location: 4, scale: 2);

            var laplace = GeneralContinuousDistribution.FromDensityFunction(
                original.Support, original.ProbabilityDensityFunction);

            testLaplace(laplace);
        }
Exemple #9
0
        public void TestLaplace()
        {
            ProbabilityDistribution normal = new LaplaceDistribution(location: 0, diversity: 1);

            double[] tester = new double[100];
            for (var i = 0; i < 100; i++)
            {
                tester[i] = normal.NextDouble();
            }

            string jsonResult = JsonConvert.SerializeObject(tester);
        }
        public void DistributionFunctionTest2()
        {
            var target = GeneralizedNormalDistribution.Laplace(location: 0.42, scale: 4.2);
            var normal = new LaplaceDistribution(location: 0.42, scale: 4.2);

            for (double x = -10; x < 10; x += 0.0001)
            {
                double actual   = target.DistributionFunction(x);
                double expected = normal.DistributionFunction(x);
                Assert.AreEqual(expected, actual, 1e-15);
                Assert.IsFalse(Double.IsNaN(actual));
            }
        }
Exemple #11
0
        public void MedianTest()
        {
            var laplace = new LaplaceDistribution(location: 2, scale: 0.42);

            var target = GeneralContinuousDistribution.FromDensityFunction(
                laplace.Support, laplace.ProbabilityDensityFunction);

            Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5));
            Assert.AreEqual(laplace.Median, target.Median, 1e-10);

            target = GeneralContinuousDistribution.FromDistributionFunction(
                laplace.Support, laplace.DistributionFunction);

            Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5), 1e-10);
            Assert.AreEqual(laplace.Median, target.Median, 1e-10);
        }
Exemple #12
0
        public void ConstructorTest6()
        {
            var original = new LaplaceDistribution(location: 4, scale: 2);

            var laplace = GeneralContinuousDistribution.FromDistributionFunction(
                original.Support, original.DistributionFunction);

            for (double i = -10; i < +10; i += 0.1)
            {
                double expected = original.ProbabilityDensityFunction(i);
                double actual   = laplace.ProbabilityDensityFunction(i);

                Assert.IsTrue(expected.IsRelativelyEqual(actual, 1e-4));
            }

            testLaplace(laplace);
        }
        public void ConstructorTest2()
        {
            var laplace = new LaplaceDistribution(location: 4, scale: 2);

            double mean   = laplace.Mean;                                     // 4.0
            double median = laplace.Median;                                   // 4.0
            double var    = laplace.Variance;                                 // 8.0
            double mode   = laplace.Mode;                                     // 4.0

            double cdf  = laplace.DistributionFunction(x: 0.27);              // 0.077448104942453522
            double pdf  = laplace.ProbabilityDensityFunction(x: 0.27);        // 0.038724052471226761
            double lpdf = laplace.LogProbabilityDensityFunction(x: 0.27);     // -3.2512943611198906

            double ccdf = laplace.ComplementaryDistributionFunction(x: 0.27); // 0.92255189505754642
            double icdf = laplace.InverseDistributionFunction(p: cdf);        // 0.27

            double hf  = laplace.HazardFunction(x: 0.27);                     // 0.041974931360160776
            double chf = laplace.CumulativeHazardFunction(x: 0.27);           // 0.080611649844768624

            string str = laplace.ToString(CultureInfo.InvariantCulture);      // Laplace(x; μ = 4, b = 2)

            Assert.AreEqual(4.0, mean);
            Assert.AreEqual(4.0, median);
            Assert.AreEqual(8.0, var);
            Assert.AreEqual(4.0, mode);
            Assert.AreEqual(0.080611649844768624, chf);
            Assert.AreEqual(0.077448104942453522, cdf);
            Assert.AreEqual(0.038724052471226761, pdf);
            Assert.AreEqual(-3.2512943611198906, lpdf);
            Assert.AreEqual(0.041974931360160776, hf);
            Assert.AreEqual(0.92255189505754642, ccdf);
            Assert.AreEqual(0.26999999840794775, icdf);
            Assert.AreEqual("Laplace(x; μ = 4, b = 2)", str);

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

            Assert.AreEqual(-0.60517019072231026, range1.Min);
            Assert.AreEqual(8.6051701894643209, range1.Max);
            Assert.AreEqual(-3.8240460108561982, range2.Min);
            Assert.AreEqual(11.824046011144626, range2.Max);
            Assert.AreEqual(-3.8240460108561951, range3.Min);
            Assert.AreEqual(11.824046011144626, range3.Max);
        }
Exemple #14
0
        public void ConstructorTest6()
        {
            var original = new LaplaceDistribution(location: 4, scale: 2);

            var laplace = GeneralContinuousDistribution.FromDistributionFunction(
                original.Support, original.DistributionFunction);

            for (double i = -10; i < +10; i += 0.1)
            {
                double expected = original.ProbabilityDensityFunction(i);
                double actual   = laplace.ProbabilityDensityFunction(i);

                double diff = Math.Abs(expected - actual);
                Assert.AreEqual(expected, actual, 1e-6);
            }

            testLaplace(laplace);
        }
Exemple #15
0
        double Sample(LocalRandom random)
        {
            // NOTE: don't use an interface and OO to select, makes JSON serialization a big mess
            switch (RateDistribution)
            {
            case RateDistribution.NormalDistribution:
                return(NormalDistribution.Sample(random, Parameters[0], Parameters[1]));

            case RateDistribution.LaplaceDistribution:
                return(LaplaceDistribution.Sample(random, Parameters[0], Parameters[1]));

            case RateDistribution.InflationModel:
                return(InflationModel.Sample(random));

            case RateDistribution.StockModel:
                return(StockModel.Sample(random));

            default:
                throw new NotImplementedException("Unknown RateType in Rate.Sample");
            }
        }
        public void LaplaceTest()
        {
            var target = GeneralizedNormalDistribution.Laplace(location: 0.42, scale: 4.2);
            var normal = new LaplaceDistribution(location: 0.42, scale: 4.2);

            test(target, normal);

            var support = target.Support;

            Assert.AreEqual(normal.Support.Min, support.Min);
            Assert.AreEqual(normal.Support.Max, support.Max);

            for (double i = 0.01; i <= 1.0; i += 0.01)
            {
                var actual   = normal.GetRange(i);
                var expected = normal.GetRange(i);

                Assert.AreEqual(expected.Min, actual.Min);
                Assert.AreEqual(expected.Max, actual.Max);
            }
        }
Exemple #17
0
 public void TestLaplaceDistribution()
 {
     double[][] para =
     {
         new double[] { 1.375, 0.5, 1.028426409720027345291384, 0.500000000000000000000000, 2.526292546497022842008996, 0.1000000000000000000000000 }
     };
     for (int i = 0; i < para.Length; i++)
     {
         var tester = new ContDistTester(para[i], delegate(double a, double b)
         {
             var ret = new LaplaceDistribution
             {
                 Mu    = a,
                 Alpha = b
             };
             return(ret);
         }
                                         );
         tester.Test(1E-14);
     }
 }
        public PositionSetEditSet getRandomPositionSet(int pointNum)
        {
            unchecked
            {
                int seed = (int)DateTime.Now.Ticks;
                this.pointNum = pointNum;
                LaplaceDistribution distributionX = new LaplaceDistribution(new StandardGenerator(seed++));
                distributionX.Alpha = X_Alpha;

                LaplaceDistribution distributionY = new LaplaceDistribution(new StandardGenerator(seed++));
                distributionY.Alpha = Y_Alpha;

                for (int i = 0; i < clusterPointNum; i++)
                {
                    distributionX.Mu = RandomMaker.RapidBetween(minMu, maxMu);
                    distributionY.Mu = RandomMaker.RapidBetween(minMu, maxMu);
                    RandomPositionSet randomPositionSet =
                        new RandomPositionSet((int)(pointNum / clusterPointNum), 1000, distributionX, distributionY);
                    positionSetEditSet.AddPositionSet(randomPositionSet);
                }
            }
            return(positionSetEditSet);
        }
        public void MedianTest()
        {
            var target = new LaplaceDistribution(location: 2, scale: 0.42);

            Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5));
        }
    /// <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");
        }
    }