// Update is called once per frame
    void Update()
    {
        timeToNextMonster -= Time.deltaTime;

        if (timeToNextMonster < 0 && !monster.active)
        {
            cenario = GenerateRandoms.cenarioSelecionado;
            //monster.GetComponent<Animator>().Play(cenario.ToString());
            timeToNextMonster = cosine(4, 8);

            double[] probs = new double[4];
            probs[0]      = 0.4;
            probs[1]      = 0.3;
            probs[2]      = 0.2;
            probs[3]      = 0.1;
            typeOfMonster = Categorical.Sample(probs);

            monster.SetActive(true);
            monster.transform.position = new Vector3(Camera.main.transform.position.x + 5, transform.position.y, transform.position.z);
            // monster.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("inimigos/" + cenario.ToString() + "/monstro" + typeOfMonster);

            monster.GetComponent <Animator>().Play(cenario.ToString() + typeOfMonster.ToString());
            Debug.Log(cenario.ToString() + typeOfMonster.ToString());
        }
    }
Beispiel #2
0
        public void TrainModel3()
        {
            var trainer = BrightWireProvider.CreateMarkovTrainer3 <string>();

            _Train(trainer);
            var model = trainer.Build().AsDictionary;

            // generate some text
            var    rand = new Random();
            string prevPrev = default(string), prev = default(string), curr = default(string);
            var    output = new List <string>();

            for (var i = 0; i < 1024; i++)
            {
                var transitions  = model.GetTransitions(prevPrev, prev, curr);
                var distribution = new Categorical(transitions.Select(d => Convert.ToDouble(d.Probability)).ToArray());
                var next         = transitions[distribution.Sample()].NextState;
                output.Add(next);
                if (SimpleTokeniser.IsEndOfSentence(next))
                {
                    break;
                }
                prevPrev = prev;
                prev     = curr;
                curr     = next;
            }
            Assert.IsTrue(output.Count < 1024);
        }
Beispiel #3
0
        public static T uniformFromArray <T>(T[] items)
        {
            double[] weights = (from i in Enumerable.Range(1, items.Length) select 1.0d).ToArray();
            int      idx     = Categorical.Sample(weights);

            return(items[idx]);
        }
Beispiel #4
0
        /// <summary>
        /// sample negative level non-uniforly with respect to the frequency items in the level and importance of level
        /// </summary>
        /// <param name="allowedLevels">The levels that user has items in</param>
        /// <returns></returns>
        protected virtual int SampleNegativeLevel(List <int> allowedLevels)
        {
            int sum = 0;

            foreach (int level in allowedLevels)
            {
                sum += LevelPosFeedback[level].Count * level;
            }

            double[] probs = new double[allowedLevels.Count + 1];
            for (int i = 0; i < allowedLevels.Count; i++)
            {
                probs[i] = (1 - UnobservedRatio) * allowedLevels[i] * LevelPosFeedback[allowedLevels[i]].Count / sum;
            }
            probs[allowedLevels.Count] = UnobservedRatio;

            int levelIndex = new Categorical(probs).Sample();

            if (levelIndex == allowedLevels.Count)
            {
                return(0);
            }

            return(allowedLevels[levelIndex]);
        }
Beispiel #5
0
        public void ValidateToString()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            var b = new Categorical(_smallP);

            Assert.AreEqual("Categorical(Dimension = 3)", b.ToString());
        }
        public void TrainModel2()
        {
            var trainer = BrightWireProvider.CreateMarkovTrainer2 <string>();

            _Train(trainer);

            // test serialisation/deserialisation
            using (var buffer = new MemoryStream()) {
                trainer.SerialiseTo(buffer);
                buffer.Position = 0;
                trainer.DeserialiseFrom(buffer, true);
            }
            var dictionary = trainer.Build().AsDictionary;

            // generate some text
            var    rand = new Random();
            string prev = default(string), curr = default(string);
            var    output = new List <string>();

            for (var i = 0; i < 1024; i++)
            {
                var transitions  = dictionary.GetTransitions(prev, curr);
                var distribution = new Categorical(transitions.Select(d => Convert.ToDouble(d.Probability)).ToArray());
                var next         = transitions[distribution.Sample()].NextState;
                output.Add(next);
                if (SimpleTokeniser.IsEndOfSentence(next))
                {
                    break;
                }
                prev = curr;
                curr = next;
            }
            Assert.IsTrue(output.Count < 1024);
        }
Beispiel #7
0
        public KMeans(int k, IReadOnlyList <IVector> data, DistanceMetric distanceMetric = DistanceMetric.Euclidean, int?randomSeed = null)
        {
            _k = k;
            _distanceMetric = distanceMetric;
            _cluster        = new ClusterData();
            _data           = data;

            // use kmeans++ to find best initial positions
            // https://normaldeviate.wordpress.com/2012/09/30/the-remarkable-k-means/
            var rand  = randomSeed.HasValue ? new Random(randomSeed.Value) : new Random();
            var data2 = data.ToList();

            // pick the first at random
            var firstIndex = rand.Next(0, data2.Count);

            _cluster.Add(data2[firstIndex]);
            data2.RemoveAt(firstIndex);

            // create a categorical distribution for each subsequent pick
            for (var i = 1; i < _k && data2.Count > 0; i++)
            {
                var probabilityList = new List <double>();
                foreach (var item in data2)
                {
                    using (var distance = _cluster.CalculateDistance(item, _distanceMetric)) {
                        var minIndex = distance.MinimumIndex();
                        probabilityList.Add(distance.AsIndexable()[minIndex]);
                    }
                }
                var distribution = new Categorical(probabilityList.ToArray());
                var nextIndex    = distribution.Sample();
                _cluster.Add(data2[nextIndex]);
                data2.RemoveAt(nextIndex);
            }
        }
Beispiel #8
0
        /// <summary>
        ///   Creates a new split-set validation algorithm.
        /// </summary>
        ///
        /// <param name="size">The total number of available samples.</param>
        /// <param name="proportion">The desired proportion of samples in the training
        /// set in comparison with the testing set.</param>
        ///
        public SplitSetValidation(int size, double proportion)
        {
            this.Proportion   = proportion;
            this.IsStratified = false;
            this.Indices      = Categorical.Random(size, proportion);

            this.ValidationSet = Indices.Find(x => x == 0);
            this.TrainingSet   = Indices.Find(x => x == 1);
        }
Beispiel #9
0
            private Multinomial(int total_count, Categorical categorical, torch.Generator generator = null) : base(generator)
            {
                this.total_count = total_count;
                this.categorical = categorical;
                this.batch_shape = categorical.batch_shape;
                var ps = categorical.param_shape;

                this.event_shape = new long[] { ps[ps.Length - 1] };
            }
Beispiel #10
0
            private Multinomial(int total_count, Categorical categorical)
            {
                this.total_count = total_count;
                this.categorical = categorical;
                this.batch_shape = categorical.batch_shape;
                var ps = categorical.param_shape;

                this.event_shape = new long[] { ps[ps.Length - 1] };
            }
Beispiel #11
0
        public void StartEpoch()
        {
            var distribution = new Categorical(_weightFunc().Select(d => Convert.ToDouble(d)).ToArray());

            _rowMap.Clear();
            for (int i = 0, len = _dataProvider.Count; i < len; i++)
            {
                _rowMap[i] = distribution.Sample();
            }
        }
        public void CanCreateCategoricalFromHistogram()
        {
            double[] smallDataset = { 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5 };
            Histogram hist = new Histogram(smallDataset, 10, 0.0, 10.0);
            var m = new Categorical(hist);

            for (int i = 0; i <= m.Maximum; i++)
            {
                AssertEx.AreEqual<double>(1.0/10.0, m.P[i]);
            }
        }
Beispiel #13
0
        public RandomProjection(ILinearAlgebraProvider lap, int fixedSize, int reducedSize, int s = 3)
        {
            _lap         = lap;
            _fixedSize   = fixedSize;
            _reducedSize = reducedSize;

            var c1           = Math.Sqrt(3);
            var distribution = new Categorical(new[] { 1.0 / (2 * s), 1 - (1.0 / s), 1.0 / (2 * s) });

            _matrix = _lap.CreateMatrix(fixedSize, reducedSize, (i, j) => Convert.ToSingle((distribution.Sample() - 1) * c1));
        }
Beispiel #14
0
        public void CanCreateCategoricalFromHistogram()
        {
            double[] smallDataset = { 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5 };
            var      hist         = new Histogram(smallDataset, 10, 0.0, 10.0);
            var      m            = new Categorical(hist);

            for (var i = 0; i <= m.Maximum; i++)
            {
                Assert.AreEqual(1.0 / 10.0, m.P[i]);
            }
        }
Beispiel #15
0
        IReadOnlyList <int> _GetNextSamples()
        {
            var distribution = new Categorical(_rowWeight.Select(d => Convert.ToDouble(d)).ToArray());
            var ret          = new List <int>();

            for (int i = 0, len = _rowWeight.Length; i < len; i++)
            {
                ret.Add(distribution.Sample());
            }
            return(ret.OrderBy(v => v).ToList());
        }
Beispiel #16
0
        /// <summary>
        /// Builds a n-gram based language model and generates new text from the model
        /// </summary>
        public static void MarkovChains()
        {
            // tokenise the novel "The Beautiful and the Damned" by F. Scott Fitzgerald
            List <IReadOnlyList <string> > sentences;

            using (var client = new WebClient()) {
                var data = client.DownloadString("http://www.gutenberg.org/cache/epub/9830/pg9830.txt");
                var pos  = data.IndexOf("CHAPTER I");
                sentences = SimpleTokeniser.FindSentences(SimpleTokeniser.Tokenise(data.Substring(pos))).ToList();
            }

            // create a markov trainer that uses a window of size 3
            var trainer = BrightWireProvider.CreateMarkovTrainer3 <string>();

            foreach (var sentence in sentences)
            {
                trainer.Add(sentence);
            }
            var model = trainer.Build().AsDictionary;

            // generate some text
            var rand = new Random();

            for (var i = 0; i < 50; i++)
            {
                var    sb = new StringBuilder();
                string prevPrev = default(string), prev = default(string), curr = default(string);
                for (var j = 0; j < 256; j++)
                {
                    var transitions  = model.GetTransitions(prevPrev, prev, curr);
                    var distribution = new Categorical(transitions.Select(d => Convert.ToDouble(d.Probability)).ToArray());
                    var next         = transitions[distribution.Sample()].NextState;
                    if (Char.IsLetterOrDigit(next[0]) && sb.Length > 0)
                    {
                        var lastChar = sb[sb.Length - 1];
                        if (lastChar != '\'' && lastChar != '-')
                        {
                            sb.Append(' ');
                        }
                    }
                    sb.Append(next);

                    if (SimpleTokeniser.IsEndOfSentence(next))
                    {
                        break;
                    }
                    prevPrev = prev;
                    prev     = curr;
                    curr     = next;
                }
                Console.WriteLine(sb.ToString());
            }
        }
 public CategoricalPrimitive(T[] items, double[] probabilities, Random gen)
 {
     Gen             = gen;
     Items           = items;
     ProbabilityMass = probabilities;
     categorical     = new Categorical(ProbabilityMass, gen);
     ItemIndex       = new Dictionary <T, int>();
     for (int c = 0; c < items.Length; c++)
     {
         ItemIndex.Add(items[c], c);
     }
 }
Beispiel #18
0
        protected override void InitModel()
        {
            base.InitModel();
            CacheSplitData();

            // initialize dynamic sampler
            _factorBasedRank = new Dictionary <int, List <string> >();

            double[] rankingPro = new double[AllItems.Count];
            double   sum        = 0;

            for (int i = 0; i < AllItems.Count; i++)
            {
                rankingPro[i] = Math.Exp(-(i + 1.0) / Lambda);
                sum          += rankingPro[i];
            }
            for (int i = 0; i < AllItems.Count; i++)
            {
                rankingPro[i] /= sum;
            }

            _rankSampler      = new Categorical(rankingPro);
            _itemFactorsStdev = new float[NumFactors];

            double[] levelPro            = new double[PosLevels.Count];
            double[] levelProUniFeedback = new double[PosLevels.Count];

            // initialize dynamic level sampler
            //if (PosSampler == PosSampler.DynamicLevel || PosSampler == PosSampler.AdaptedWeight)
            {
                // key is levelNo, value id list of feedback in that level
                sum = LevelPosFeedback.Sum(kv => kv.Key * kv.Value.Count);

                for (int i = 0; i < PosLevels.Count; i++)
                {
                    levelPro[i]            = 1.0f * PosLevels[i] * LevelPosFeedback[PosLevels[i]].Count / sum;
                    levelProUniFeedback[i] = 1 / sum;
                }
                _posLevelSampler            = new Categorical(levelPro);
                _posLevelUniFeedbackSampler = new Categorical(levelProUniFeedback);
            }

            // this sampler specifies whether the negative sample should be sampled from observed or unobserved feedback
            // the parameter of this distributio is parameter beta in Loni_RecSys2016
            // with beta=1 always unobserved will be sampled but with beta = 0 always observed will be sampled (if possible)
            _unobservedOrNegativeSampler = new Categorical(new double[] { (1 - UnobservedRatio), UnobservedRatio });
        }
Beispiel #19
0
        protected virtual void UpdatePosSampler()
        {
            double[] levelsAvg = new double[PosLevels.Count];
            for (int i = 0; i < PosLevels.Count; i++)
            {
                foreach (Feedback f in LevelPosFeedback[PosLevels[i]])
                {
                    int user_id = UsersMap.ToInternalID(f.User.Id);
                    int item_id = ItemsMap.ToInternalID(f.Item.Id);

                    levelsAvg[i] += MatrixExtensions.RowScalarProduct(user_factors, user_id, item_factors, item_id);
                }
                //Console.WriteLine(levelsAvg[i]);
                levelsAvg[i] /= LevelPosFeedback[PosLevels[i]].Count;
            }

            double avgSum = levelsAvg.Sum();

            double[] levelWeights = new double[PosLevels.Count];

            for (int i = 0; i < PosLevels.Count; i++)
            {
                levelWeights[i] = levelsAvg[i] / avgSum;
            }

            double sum = 0;

            for (int i = 0; i < PosLevels.Count; i++)
            {
                sum += levelWeights[i] * LevelPosFeedback[PosLevels[i]].Count;
            }

            double[] levelPros = new double[PosLevels.Count];
            for (int i = 0; i < PosLevels.Count; i++)
            {
                levelPros[i] = levelWeights[i] * LevelPosFeedback[PosLevels[i]].Count / sum;
            }

            string weights = levelWeights.Select(p => string.Format("{0:0.00}", p)).Aggregate((a, b) => a + " " + b);

            Logger.Current.Info(weights);
            //var temp = SampledCount.Values.Take(10).Select(i => i.ToString()).Aggregate((a, b) => a + " " + b);
            //Console.WriteLine(temp);
            _posLevelSampler = new Categorical(levelPros);
        }
Beispiel #20
0
        public virtual Feedback SampleLeastPopularPosFeedback()
        {
            int user_id = SampleUser();

            var user = Split.Container.Users[UsersMap.ToOriginalID(user_id)];

            var userFeedback = user.Feedbacks.Where(f => f.SliceType == FeedbackSlice.TRAIN).ToList();

            double[] itemProbs = userFeedback.Select(f => 1.0 / Math.Log(SampledCount[f.Item.Id] + 1, 2)).ToArray();

            var fIx = new Categorical(itemProbs).Sample();

            Feedback posFeedback = userFeedback[fIx];

            SampledCount[posFeedback.Item.Id]++;

            return(posFeedback);
        }
Beispiel #21
0
        protected virtual string SampleNegItemDynamic(Feedback posFeedback)
        {
            // sample r
            int r;

            do
            {
                r = _rankSampler.Sample();
            } while (r >= AllItems.Count);

            int user_id = UsersMap.ToInternalID(posFeedback.User.Id);
            var u       = user_factors.GetRow(user_id);

            // sample f from p(f|c)
            double sum = 0;

            for (int i = 0; i < NumFactors; i++)
            {
                sum += Math.Abs(u[i]) * _itemFactorsStdev[i];
            }

            double[] probs = new double[NumFactors];
            for (int i = 0; i < NumFactors; i++)
            {
                probs[i] = Math.Abs(u[i]) * _itemFactorsStdev[i] / sum;
            }

            int f = new Categorical(probs).Sample();

            // take item j (negItemId) from position r of the list of sampled f
            string negItemId;

            if (Math.Sign(user_factors[user_id, f]) > 0)
            {
                negItemId = _factorBasedRank[f][r];
            }
            else
            {
                negItemId = _factorBasedRank[f][AllItems.Count - r - 1];
            }

            return(negItemId);
        }
        /// <summary>
        ///   Constructs a Multinomial Logistic Regression Analysis.
        /// </summary>
        ///
        /// <param name="inputs">The input data for the analysis.</param>
        /// <param name="outputs">The output data for the analysis.</param>
        ///
        public MultinomialLogisticRegressionAnalysis(double[][] inputs, int[] outputs)
        {
            // Initial argument checking
            if (inputs == null)
            {
                throw new ArgumentNullException("inputs");
            }

            if (outputs == null)
            {
                throw new ArgumentNullException("outputs");
            }

            if (inputs.Length != outputs.Length)
            {
                throw new ArgumentException("The number of rows in the input array must match the number of given outputs.");
            }

            init(inputs, Categorical.OneHot(outputs));
        }
Beispiel #23
0
        /// <summary>
        ///   Processes the current filter.
        /// </summary>
        ///
        protected override DataTable ProcessFilter(DataTable data)
        {
            if (!lockGroups)
            {
                // Check if we should balance label proportions
                if (Columns.Count == 0)
                {
                    // No. Just generate assign groups at random
                    groupIndices = Categorical.Random(data.Rows.Count, Proportion);
                }

                else
                {
                    // Yes, we must balance the occurrences in a data column
                    groupIndices = balancedGroups(data);
                }
            }

            return(apply(data));
        }
Beispiel #24
0
        public List <Quiz> GetQuizCategory(List <Quiz> UnsortedList, QuizCategory category)
        {//Function to return list of quiz questions based off of category selected by user
            List <Quiz> Categorical = new List <Quiz>();

            if (category == QuizCategory.All)
            {
                Categorical = UnsortedList;
            }
            else
            {
                foreach (Quiz quiz in UnsortedList)
                {
                    if (quiz.Category == category)
                    {
                        Categorical.Add(quiz);
                    }
                }
            }
            return(Categorical);
        }
        public IList <NeuralNetwork> ApplySelection(IList <GeneticAlgorithmAgent> agents)
        {
            int   populationCount = agents.Count;
            float fitnessSum      = agents.Select(agent => agent.Fitness).Sum();
            var   probabilities   = new double[populationCount];

            for (int i = 0; i < populationCount; i++)
            {
                probabilities[i] = (double)agents[i].Fitness / (double)fitnessSum;
            }

            var distribution  = new Categorical(probabilities);
            var newPopulation = new List <NeuralNetwork>();

            for (int i = 0; i < populationCount; i++)
            {
                newPopulation.Add(agents[distribution.Sample()].Network.Clone());
            }

            return(newPopulation);
        }
        /// <summary>
        ///   Runs the learning algorithm.
        /// </summary>
        ///
        /// <remarks>
        ///   Learning problem. Given some training observation sequences O = {o1, o2, ..., oK}
        ///   and general structure of HMM (numbers of hidden and visible states), determine
        ///   HMM parameters M = (A, B, pi) that best fit training data.
        /// </remarks>
        ///
        public double Run(params T[] observations)
        {
            convergence.Clear();

            double newLogLikelihood = Double.NegativeInfinity;

            int[][] paths = new int[observations.Length][];


            do // Until convergence or max iterations is reached
            {
                if (batches == 1)
                {
                    RunEpoch(observations, paths);
                }
                else
                {
                    // Divide in batches
                    int[] groups = Categorical.Random(observations.Length, batches);

                    // For each batch
                    for (int j = 0; j < batches; j++)
                    {
                        var idx     = groups.Find(x => x == j);
                        var inputs  = observations.Submatrix(idx);
                        var outputs = paths.Submatrix(idx);
                        RunEpoch(inputs, outputs);
                    }
                }

                // Compute log-likelihood
                newLogLikelihood = ComputeLogLikelihood(observations);

                // Check convergence
                convergence.NewValue = newLogLikelihood;
            } while (!convergence.HasConverged);

            return(newLogLikelihood);
        }
    // Update is called once per frame
    void Update()
    {
        if (!item.active)
        {
            timeToNextItem -= Time.deltaTime;
            if (timeToNextItem < 0)
            {
                timeToNextItem = cosine(30, 45);
                double[] probs = new double[4];
                probs[0] = 0.4;
                probs[1] = 0.3;
                probs[2] = 0.2;
                probs[3] = 0.1;
                int    typeOfItem = Categorical.Sample(probs);
                Camera cam        = Camera.main;
                float  height     = 2f * cam.orthographicSize;
                float  width      = height * cam.aspect;
                item.SetActive(true);
                item.transform.position = new Vector3(cam.transform.position.x + 4, transform.position.y, transform.position.z);

                if (typeOfItem == 0)
                {
                    item.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Itens/potion");
                }
                else if (typeOfItem == 1)
                {
                    item.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Itens/pill");
                }
                else if (typeOfItem == 2)
                {
                    item.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Itens/medicine");
                }
                else if (typeOfItem == 3)
                {
                    item.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Itens/backpack");
                }
            }
        }
    }
Beispiel #28
0
        static void Main(string[] args)
        {
            int increment         = 10;      // how much inverse probabilities are updated per sample
            int guidanceParameter = 1000000; // Small one - consequtive sampling is more affected by outcome. Large one - closer to uniform sampling

            int[]    invprob       = new int [6];
            double[] probabilities = new double [6];

            int[] counter = new int [] { 0, 0, 0, 0, 0, 0 };
            int[] repeat  = new int [] { 0, 0, 0, 0, 0, 0 };
            int   prev    = -1;

            for (int k = 0; k != 100000; ++k)
            {
                if (k % 60 == 0)        // drop accumulation, important for low guidance
                {
                    for (int i = 0; i != 6; ++i)
                    {
                        invprob[i] = guidanceParameter;
                    }
                }
                for (int i = 0; i != 6; ++i)
                {
                    probabilities[i] = 1.0 / (double)invprob[i];
                }
                var cat = new Categorical(probabilities);
                var q   = cat.Sample();
                counter[q] += 1;
                invprob[q] += increment;
                if (q == prev)
                {
                    repeat[q] += 1;
                }
                prev = q;
            }
            counter.ToList().ForEach(Console.WriteLine);
            repeat.ToList().ForEach(Console.WriteLine);
        }
Beispiel #29
0
        public IList <NeuralNetwork> ApplySelection(IList <GeneticAlgorithmAgent> agents)
        {
            IList <GeneticAlgorithmAgent> agentsSorted = agents
                                                         .OrderBy(agent => agent.Fitness)
                                                         .ToList();

            int populationCount = agentsSorted.Count;

            double[] probabilities = Enumerable
                                     .Range(0, populationCount)
                                     .Select(i => (double)(2 * i) / (populationCount * (populationCount - 1)))
                                     .ToArray();

            var distribution  = new Categorical(probabilities);
            var newPopulation = new List <NeuralNetwork>();

            for (int i = 0; i < populationCount; i++)
            {
                newPopulation.Add(agentsSorted[distribution.Sample()].Network.Clone());
            }

            return(newPopulation);
        }
 public void SetProbabilityFails()
 {
     var b = new Categorical(_largeP);
     Assert.Throws<ArgumentOutOfRangeException>(() => b.P = _badP);
 }
 public void SetProbabilityFails()
 {
     var b = new Categorical(_largeP);
     Assert.That(() => b.P = _badP, Throws.ArgumentException);
 }
Beispiel #32
0
        public override void ExecuteExample()
        {
            // <a href="http://en.wikipedia.org/wiki/Binomial_distribution">Binomial distribution</a>
            MathDisplay.WriteLine("<b>Binomial distribution</b>");
            // 1. Initialize the new instance of the Binomial distribution class with parameters P = 0.2, N = 20
            var binomial = new Binomial(0.2, 20);

            MathDisplay.WriteLine(@"1. Initialize the new instance of the Binomial distribution class with parameters P = {0}, N = {1}", binomial.P, binomial.N);
            MathDisplay.WriteLine();

            // 2. Distributuion properties:
            MathDisplay.WriteLine(@"2. {0} distributuion properties:", binomial);

            // Cumulative distribution function
            MathDisplay.WriteLine(@"{0} - Сumulative distribution at location '3'", binomial.CumulativeDistribution(3).ToString(" #0.00000;-#0.00000"));

            // Probability density
            MathDisplay.WriteLine(@"{0} - Probability mass at location '3'", binomial.Probability(3).ToString(" #0.00000;-#0.00000"));

            // Log probability density
            MathDisplay.WriteLine(@"{0} - Log probability mass at location '3'", binomial.ProbabilityLn(3).ToString(" #0.00000;-#0.00000"));

            // Entropy
            MathDisplay.WriteLine(@"{0} - Entropy", binomial.Entropy.ToString(" #0.00000;-#0.00000"));

            // Largest element in the domain
            MathDisplay.WriteLine(@"{0} - Largest element in the domain", binomial.Maximum.ToString(" #0.00000;-#0.00000"));

            // Smallest element in the domain
            MathDisplay.WriteLine(@"{0} - Smallest element in the domain", binomial.Minimum.ToString(" #0.00000;-#0.00000"));

            // Mean
            MathDisplay.WriteLine(@"{0} - Mean", binomial.Mean.ToString(" #0.00000;-#0.00000"));

            // Median
            MathDisplay.WriteLine(@"{0} - Median", binomial.Median.ToString(" #0.00000;-#0.00000"));

            // Mode
            MathDisplay.WriteLine(@"{0} - Mode", binomial.Mode.ToString(" #0.00000;-#0.00000"));

            // Variance
            MathDisplay.WriteLine(@"{0} - Variance", binomial.Variance.ToString(" #0.00000;-#0.00000"));

            // Standard deviation
            MathDisplay.WriteLine(@"{0} - Standard deviation", binomial.StdDev.ToString(" #0.00000;-#0.00000"));

            // Skewness
            MathDisplay.WriteLine(@"{0} - Skewness", binomial.Skewness.ToString(" #0.00000;-#0.00000"));
            MathDisplay.WriteLine();

            // 3. Generate 10 samples of the Binomial distribution
            MathDisplay.WriteLine(@"3. Generate 10 samples of the Binomial distribution");
            for (var i = 0; i < 10; i++)
            {
                MathDisplay.Write(binomial.Sample().ToString("N05") + @" ");
            }
            MathDisplay.FlushBuffer();
            MathDisplay.WriteLine();
            MathDisplay.WriteLine();


            // <a href="http://en.wikipedia.org/wiki/Bernoulli_distribution">Bernoulli distribution</a>
            MathDisplay.WriteLine("<b>Bernoulli distribution</b>");
            // 1. Initialize the new instance of the Bernoulli distribution class with parameter P = 0.2
            var bernoulli = new Bernoulli(0.2);

            MathDisplay.WriteLine(@"1. Initialize the new instance of the Bernoulli distribution class with parameter P = {0}", bernoulli.P);
            MathDisplay.WriteLine();

            // 2. Distributuion properties:
            MathDisplay.WriteLine(@"2. {0} distributuion properties:", bernoulli);

            // Cumulative distribution function
            MathDisplay.WriteLine(@"{0} - Сumulative distribution at location '3'", bernoulli.CumulativeDistribution(3).ToString(" #0.00000;-#0.00000"));

            // Probability density
            MathDisplay.WriteLine(@"{0} - Probability mass at location '3'", bernoulli.Probability(3).ToString(" #0.00000;-#0.00000"));

            // Log probability density
            MathDisplay.WriteLine(@"{0} - Log probability mass at location '3'", bernoulli.ProbabilityLn(3).ToString(" #0.00000;-#0.00000"));

            // Entropy
            MathDisplay.WriteLine(@"{0} - Entropy", bernoulli.Entropy.ToString(" #0.00000;-#0.00000"));

            // Largest element in the domain
            MathDisplay.WriteLine(@"{0} - Largest element in the domain", bernoulli.Maximum.ToString(" #0.00000;-#0.00000"));

            // Smallest element in the domain
            MathDisplay.WriteLine(@"{0} - Smallest element in the domain", bernoulli.Minimum.ToString(" #0.00000;-#0.00000"));

            // Mean
            MathDisplay.WriteLine(@"{0} - Mean", bernoulli.Mean.ToString(" #0.00000;-#0.00000"));

            // Mode
            MathDisplay.WriteLine(@"{0} - Mode", bernoulli.Mode.ToString(" #0.00000;-#0.00000"));

            // Variance
            MathDisplay.WriteLine(@"{0} - Variance", bernoulli.Variance.ToString(" #0.00000;-#0.00000"));

            // Standard deviation
            MathDisplay.WriteLine(@"{0} - Standard deviation", bernoulli.StdDev.ToString(" #0.00000;-#0.00000"));

            // Skewness
            MathDisplay.WriteLine(@"{0} - Skewness", bernoulli.Skewness.ToString(" #0.00000;-#0.00000"));
            MathDisplay.WriteLine();

            // 3. Generate 10 samples of the Bernoulli distribution
            MathDisplay.WriteLine(@"3. Generate 10 samples of the Bernoulli distribution");
            for (var i = 0; i < 10; i++)
            {
                MathDisplay.Write(bernoulli.Sample().ToString("N05") + @" ");
            }
            MathDisplay.FlushBuffer();
            MathDisplay.WriteLine();
            MathDisplay.WriteLine();


            // <a href="http://en.wikipedia.org/wiki/Categorical_distribution">Categorical distribution</a>
            MathDisplay.WriteLine("<b>Categorical distribution</b>");
            // 1. Initialize the new instance of the Categorical distribution class with parameters P = (0.1, 0.2, 0.25, 0.45)
            var binomialC = new Categorical(new[] { 0.1, 0.2, 0.25, 0.45 });

            MathDisplay.WriteLine(@"1. Initialize the new instance of the Categorical distribution class with parameters P = (0.1, 0.2, 0.25, 0.45)");
            MathDisplay.WriteLine();

            // 2. Distributuion properties:
            MathDisplay.WriteLine(@"2. {0} distributuion properties:", binomialC);

            // Cumulative distribution function
            MathDisplay.WriteLine(@"{0} - Сumulative distribution at location '3'", binomialC.CumulativeDistribution(3).ToString(" #0.00000;-#0.00000"));

            // Probability density
            MathDisplay.WriteLine(@"{0} - Probability mass at location '3'", binomialC.Probability(3).ToString(" #0.00000;-#0.00000"));

            // Log probability density
            MathDisplay.WriteLine(@"{0} - Log probability mass at location '3'", binomialC.ProbabilityLn(3).ToString(" #0.00000;-#0.00000"));

            // Entropy
            MathDisplay.WriteLine(@"{0} - Entropy", binomialC.Entropy.ToString(" #0.00000;-#0.00000"));

            // Largest element in the domain
            MathDisplay.WriteLine(@"{0} - Largest element in the domain", binomialC.Maximum.ToString(" #0.00000;-#0.00000"));

            // Smallest element in the domain
            MathDisplay.WriteLine(@"{0} - Smallest element in the domain", binomialC.Minimum.ToString(" #0.00000;-#0.00000"));

            // Mean
            MathDisplay.WriteLine(@"{0} - Mean", binomialC.Mean.ToString(" #0.00000;-#0.00000"));

            // Median
            MathDisplay.WriteLine(@"{0} - Median", binomialC.Median.ToString(" #0.00000;-#0.00000"));

            // Variance
            MathDisplay.WriteLine(@"{0} - Variance", binomialC.Variance.ToString(" #0.00000;-#0.00000"));

            // Standard deviation
            MathDisplay.WriteLine(@"{0} - Standard deviation", binomialC.StdDev.ToString(" #0.00000;-#0.00000"));

            // 3. Generate 10 samples of the Categorical distribution
            MathDisplay.WriteLine(@"3. Generate 10 samples of the Categorical distribution");
            for (var i = 0; i < 10; i++)
            {
                MathDisplay.Write(binomialC.Sample().ToString("N05") + @" ");
            }
            MathDisplay.FlushBuffer();
            MathDisplay.WriteLine();
            MathDisplay.WriteLine();


            // <a href="http://en.wikipedia.org/wiki/Conway%E2%80%93Maxwell%E2%80%93Poisson_distribution">ConwayMaxwellPoisson distribution</a>
            MathDisplay.WriteLine("<b>Conway Maxwell Poisson distribution</b>");
            // 1. Initialize the new instance of the ConwayMaxwellPoisson distribution class with parameters Lambda = 2, Nu = 1
            var conwayMaxwellPoisson = new ConwayMaxwellPoisson(2, 1);

            MathDisplay.WriteLine(@"1. Initialize the new instance of the ConwayMaxwellPoisson distribution class with parameters Lambda = {0}, Nu = {1}", conwayMaxwellPoisson.Lambda, conwayMaxwellPoisson.Nu);
            MathDisplay.WriteLine();

            // 2. Distributuion properties:
            MathDisplay.WriteLine(@"2. {0} distributuion properties:", conwayMaxwellPoisson);

            // Cumulative distribution function
            MathDisplay.WriteLine(@"{0} - Сumulative distribution at location '3'", conwayMaxwellPoisson.CumulativeDistribution(3).ToString(" #0.00000;-#0.00000"));

            // Probability density
            MathDisplay.WriteLine(@"{0} - Probability mass at location '3'", conwayMaxwellPoisson.Probability(3).ToString(" #0.00000;-#0.00000"));

            // Log probability density
            MathDisplay.WriteLine(@"{0} - Log probability mass at location '3'", conwayMaxwellPoisson.ProbabilityLn(3).ToString(" #0.00000;-#0.00000"));

            // Smallest element in the domain
            MathDisplay.WriteLine(@"{0} - Smallest element in the domain", conwayMaxwellPoisson.Minimum.ToString(" #0.00000;-#0.00000"));

            // Mean
            MathDisplay.WriteLine(@"{0} - Mean", conwayMaxwellPoisson.Mean.ToString(" #0.00000;-#0.00000"));

            // Variance
            MathDisplay.WriteLine(@"{0} - Variance", conwayMaxwellPoisson.Variance.ToString(" #0.00000;-#0.00000"));

            // Standard deviation
            MathDisplay.WriteLine(@"{0} - Standard deviation", conwayMaxwellPoisson.StdDev.ToString(" #0.00000;-#0.00000"));
            MathDisplay.WriteLine();

            // 3. Generate 10 samples of the ConwayMaxwellPoisson distribution
            MathDisplay.WriteLine(@"3. Generate 10 samples of the ConwayMaxwellPoisson distribution");
            for (var i = 0; i < 10; i++)
            {
                MathDisplay.Write(conwayMaxwellPoisson.Sample().ToString("N05") + @" ");
            }
            MathDisplay.FlushBuffer();
            MathDisplay.WriteLine();
            MathDisplay.WriteLine();


            // <a href="http://en.wikipedia.org/wiki/Discrete_uniform">DiscreteUniform distribution</a>
            MathDisplay.WriteLine("<b>Discrete Uniform distribution</b>");
            // 1. Initialize the new instance of the DiscreteUniform distribution class with parameters LowerBound = 2, UpperBound = 10
            var discreteUniform = new DiscreteUniform(2, 10);

            MathDisplay.WriteLine(@"1. Initialize the new instance of the DiscreteUniform distribution class with parameters LowerBound = {0}, UpperBound = {1}", discreteUniform.LowerBound, discreteUniform.UpperBound);
            MathDisplay.WriteLine();

            // 2. Distributuion properties:
            MathDisplay.WriteLine(@"2. {0} distributuion properties:", discreteUniform);

            // Cumulative distribution function
            MathDisplay.WriteLine(@"{0} - Сumulative distribution at location '3'", discreteUniform.CumulativeDistribution(3).ToString(" #0.00000;-#0.00000"));

            // Probability density
            MathDisplay.WriteLine(@"{0} - Probability mass at location '3'", discreteUniform.Probability(3).ToString(" #0.00000;-#0.00000"));

            // Log probability density
            MathDisplay.WriteLine(@"{0} - Log probability mass at location '3'", discreteUniform.ProbabilityLn(3).ToString(" #0.00000;-#0.00000"));

            // Entropy
            MathDisplay.WriteLine(@"{0} - Entropy", discreteUniform.Entropy.ToString(" #0.00000;-#0.00000"));

            // Largest element in the domain
            MathDisplay.WriteLine(@"{0} - Largest element in the domain", discreteUniform.Maximum.ToString(" #0.00000;-#0.00000"));

            // Smallest element in the domain
            MathDisplay.WriteLine(@"{0} - Smallest element in the domain", discreteUniform.Minimum.ToString(" #0.00000;-#0.00000"));

            // Mean
            MathDisplay.WriteLine(@"{0} - Mean", discreteUniform.Mean.ToString(" #0.00000;-#0.00000"));

            // Median
            MathDisplay.WriteLine(@"{0} - Median", discreteUniform.Median.ToString(" #0.00000;-#0.00000"));

            // Mode
            MathDisplay.WriteLine(@"{0} - Mode", discreteUniform.Mode.ToString(" #0.00000;-#0.00000"));

            // Variance
            MathDisplay.WriteLine(@"{0} - Variance", discreteUniform.Variance.ToString(" #0.00000;-#0.00000"));

            // Standard deviation
            MathDisplay.WriteLine(@"{0} - Standard deviation", discreteUniform.StdDev.ToString(" #0.00000;-#0.00000"));

            // Skewness
            MathDisplay.WriteLine(@"{0} - Skewness", discreteUniform.Skewness.ToString(" #0.00000;-#0.00000"));
            MathDisplay.WriteLine();

            // 3. Generate 10 samples of the DiscreteUniform distribution
            MathDisplay.WriteLine(@"3. Generate 10 samples of the DiscreteUniform distribution");
            for (var i = 0; i < 10; i++)
            {
                MathDisplay.Write(discreteUniform.Sample().ToString("N05") + @" ");
            }
            MathDisplay.FlushBuffer();
            MathDisplay.WriteLine();
            MathDisplay.WriteLine();


            // <a href="http://en.wikipedia.org/wiki/Geometric_distribution">Geometric distribution</a>
            MathDisplay.WriteLine("<b>Geometric distribution</b>");
            // 1. Initialize the new instance of the Geometric distribution class with parameter P = 0.2
            var geometric = new Geometric(0.2);

            MathDisplay.WriteLine(@"1. Initialize the new instance of the Geometric distribution class with parameter P = {0}", geometric.P);
            MathDisplay.WriteLine();

            // 2. Distributuion properties:
            MathDisplay.WriteLine(@"2. {0} distributuion properties:", geometric);

            // Cumulative distribution function
            MathDisplay.WriteLine(@"{0} - Сumulative distribution at location '3'", geometric.CumulativeDistribution(3).ToString(" #0.00000;-#0.00000"));

            // Probability density
            MathDisplay.WriteLine(@"{0} - Probability mass at location '3'", geometric.Probability(3).ToString(" #0.00000;-#0.00000"));

            // Log probability density
            MathDisplay.WriteLine(@"{0} - Log probability mass at location '3'", geometric.ProbabilityLn(3).ToString(" #0.00000;-#0.00000"));

            // Entropy
            MathDisplay.WriteLine(@"{0} - Entropy", geometric.Entropy.ToString(" #0.00000;-#0.00000"));

            // Largest element in the domain
            MathDisplay.WriteLine(@"{0} - Largest element in the domain", geometric.Maximum.ToString(" #0.00000;-#0.00000"));

            // Smallest element in the domain
            MathDisplay.WriteLine(@"{0} - Smallest element in the domain", geometric.Minimum.ToString(" #0.00000;-#0.00000"));

            // Mean
            MathDisplay.WriteLine(@"{0} - Mean", geometric.Mean.ToString(" #0.00000;-#0.00000"));

            // Median
            MathDisplay.WriteLine(@"{0} - Median", geometric.Median.ToString(" #0.00000;-#0.00000"));

            // Mode
            MathDisplay.WriteLine(@"{0} - Mode", geometric.Mode.ToString(" #0.00000;-#0.00000"));

            // Variance
            MathDisplay.WriteLine(@"{0} - Variance", geometric.Variance.ToString(" #0.00000;-#0.00000"));

            // Standard deviation
            MathDisplay.WriteLine(@"{0} - Standard deviation", geometric.StdDev.ToString(" #0.00000;-#0.00000"));

            // Skewness
            MathDisplay.WriteLine(@"{0} - Skewness", geometric.Skewness.ToString(" #0.00000;-#0.00000"));
            MathDisplay.WriteLine();

            // 3. Generate 10 samples of the Geometric distribution
            MathDisplay.WriteLine(@"3. Generate 10 samples of the Geometric distribution");
            for (var i = 0; i < 10; i++)
            {
                MathDisplay.Write(geometric.Sample().ToString("N05") + @" ");
            }
            MathDisplay.FlushBuffer();
            MathDisplay.WriteLine();
            MathDisplay.WriteLine();


            // <a href="http://en.wikipedia.org/wiki/Hypergeometric_distribution">Hypergeometric distribution</a>
            MathDisplay.WriteLine("<b>Hypergeometric distribution</b>");
            // 1. Initialize the new instance of the Hypergeometric distribution class with parameters PopulationSize = 10, M = 2, N = 8
            var hypergeometric = new Hypergeometric(30, 15, 10);

            MathDisplay.WriteLine(@"1. Initialize the new instance of the Hypergeometric distribution class with parameters Population = {0}, Success = {1}, Draws = {2}", hypergeometric.Population, hypergeometric.Success, hypergeometric.Draws);
            MathDisplay.WriteLine();

            // 2. Distributuion properties:
            MathDisplay.WriteLine(@"2. {0} distributuion properties:", hypergeometric);

            // Cumulative distribution function
            MathDisplay.WriteLine(@"{0} - Сumulative distribution at location '3'", hypergeometric.CumulativeDistribution(3).ToString(" #0.00000;-#0.00000"));

            // Probability density
            MathDisplay.WriteLine(@"{0} - Probability mass at location '3'", hypergeometric.Probability(3).ToString(" #0.00000;-#0.00000"));

            // Log probability density
            MathDisplay.WriteLine(@"{0} - Log probability mass at location '3'", hypergeometric.ProbabilityLn(3).ToString(" #0.00000;-#0.00000"));

            // Largest element in the domain
            MathDisplay.WriteLine(@"{0} - Largest element in the domain", hypergeometric.Maximum.ToString(" #0.00000;-#0.00000"));

            // Smallest element in the domain
            MathDisplay.WriteLine(@"{0} - Smallest element in the domain", hypergeometric.Minimum.ToString(" #0.00000;-#0.00000"));

            // Mean
            MathDisplay.WriteLine(@"{0} - Mean", hypergeometric.Mean.ToString(" #0.00000;-#0.00000"));

            // Mode
            MathDisplay.WriteLine(@"{0} - Mode", hypergeometric.Mode.ToString(" #0.00000;-#0.00000"));

            // Variance
            MathDisplay.WriteLine(@"{0} - Variance", hypergeometric.Variance.ToString(" #0.00000;-#0.00000"));

            // Standard deviation
            MathDisplay.WriteLine(@"{0} - Standard deviation", hypergeometric.StdDev.ToString(" #0.00000;-#0.00000"));

            // Skewness
            MathDisplay.WriteLine(@"{0} - Skewness", hypergeometric.Skewness.ToString(" #0.00000;-#0.00000"));
            MathDisplay.WriteLine();

            // 3. Generate 10 samples of the Hypergeometric distribution
            MathDisplay.WriteLine(@"3. Generate 10 samples of the Hypergeometric distribution");
            for (var i = 0; i < 10; i++)
            {
                MathDisplay.Write(hypergeometric.Sample().ToString("N05") + @" ");
            }
            MathDisplay.FlushBuffer();
            MathDisplay.WriteLine();
            MathDisplay.WriteLine();


            // <a href="http://en.wikipedia.org/wiki/Negative_binomial">NegativeBinomial distribution</a>
            MathDisplay.WriteLine("<b>Negative Binomial distribution</b>");
            // 1. Initialize the new instance of the NegativeBinomial distribution class with parameters P = 0.2, R = 20
            var negativeBinomial = new NegativeBinomial(20, 0.2);

            MathDisplay.WriteLine(@"1. Initialize the new instance of the NegativeBinomial distribution class with parameters P = {0}, N = {1}", negativeBinomial.P, negativeBinomial.R);
            MathDisplay.WriteLine();

            // 2. Distributuion properties:
            MathDisplay.WriteLine(@"2. {0} distributuion properties:", negativeBinomial);

            // Cumulative distribution function
            MathDisplay.WriteLine(@"{0} - Сumulative distribution at location '3'", negativeBinomial.CumulativeDistribution(3).ToString(" #0.00000;-#0.00000"));

            // Probability density
            MathDisplay.WriteLine(@"{0} - Probability mass at location '3'", negativeBinomial.Probability(3).ToString(" #0.00000;-#0.00000"));

            // Log probability density
            MathDisplay.WriteLine(@"{0} - Log probability mass at location '3'", negativeBinomial.ProbabilityLn(3).ToString(" #0.00000;-#0.00000"));

            // Largest element in the domain
            MathDisplay.WriteLine(@"{0} - Largest element in the domain", negativeBinomial.Maximum.ToString(" #0.00000;-#0.00000"));

            // Smallest element in the domain
            MathDisplay.WriteLine(@"{0} - Smallest element in the domain", negativeBinomial.Minimum.ToString(" #0.00000;-#0.00000"));

            // Mean
            MathDisplay.WriteLine(@"{0} - Mean", negativeBinomial.Mean.ToString(" #0.00000;-#0.00000"));

            // Mode
            MathDisplay.WriteLine(@"{0} - Mode", negativeBinomial.Mode.ToString(" #0.00000;-#0.00000"));

            // Variance
            MathDisplay.WriteLine(@"{0} - Variance", negativeBinomial.Variance.ToString(" #0.00000;-#0.00000"));

            // Standard deviation
            MathDisplay.WriteLine(@"{0} - Standard deviation", negativeBinomial.StdDev.ToString(" #0.00000;-#0.00000"));

            // Skewness
            MathDisplay.WriteLine(@"{0} - Skewness", negativeBinomial.Skewness.ToString(" #0.00000;-#0.00000"));
            MathDisplay.WriteLine();

            // 3. Generate 10 samples of the NegativeBinomial distribution
            MathDisplay.WriteLine(@"3. Generate 10 samples of the NegativeBinomial distribution");
            for (var i = 0; i < 10; i++)
            {
                MathDisplay.Write(negativeBinomial.Sample().ToString("N05") + @" ");
            }
            MathDisplay.FlushBuffer();
            MathDisplay.WriteLine();
            MathDisplay.WriteLine();


            // <a href="http://en.wikipedia.org/wiki/Poisson_distribution">Poisson distribution</a>
            MathDisplay.WriteLine("<b>Poisson distribution</b>");
            // 1. Initialize the new instance of the Poisson distribution class with parameter Lambda = 1
            var poisson = new Poisson(1);

            MathDisplay.WriteLine(@"1. Initialize the new instance of the Poisson distribution class with parameter Lambda = {0}", poisson.Lambda);
            MathDisplay.WriteLine();

            // 2. Distributuion properties:
            MathDisplay.WriteLine(@"2. {0} distributuion properties:", poisson);

            // Cumulative distribution function
            MathDisplay.WriteLine(@"{0} - Сumulative distribution at location '3'", poisson.CumulativeDistribution(3).ToString(" #0.00000;-#0.00000"));

            // Probability density
            MathDisplay.WriteLine(@"{0} - Probability mass at location '3'", poisson.Probability(3).ToString(" #0.00000;-#0.00000"));

            // Log probability density
            MathDisplay.WriteLine(@"{0} - Log probability mass at location '3'", poisson.ProbabilityLn(3).ToString(" #0.00000;-#0.00000"));

            // Entropy
            MathDisplay.WriteLine(@"{0} - Entropy", poisson.Entropy.ToString(" #0.00000;-#0.00000"));

            // Largest element in the domain
            MathDisplay.WriteLine(@"{0} - Largest element in the domain", poisson.Maximum.ToString(" #0.00000;-#0.00000"));

            // Smallest element in the domain
            MathDisplay.WriteLine(@"{0} - Smallest element in the domain", poisson.Minimum.ToString(" #0.00000;-#0.00000"));

            // Mean
            MathDisplay.WriteLine(@"{0} - Mean", poisson.Mean.ToString(" #0.00000;-#0.00000"));

            // Median
            MathDisplay.WriteLine(@"{0} - Median", poisson.Median.ToString(" #0.00000;-#0.00000"));

            // Mode
            MathDisplay.WriteLine(@"{0} - Mode", poisson.Mode.ToString(" #0.00000;-#0.00000"));

            // Variance
            MathDisplay.WriteLine(@"{0} - Variance", poisson.Variance.ToString(" #0.00000;-#0.00000"));

            // Standard deviation
            MathDisplay.WriteLine(@"{0} - Standard deviation", poisson.StdDev.ToString(" #0.00000;-#0.00000"));

            // Skewness
            MathDisplay.WriteLine(@"{0} - Skewness", poisson.Skewness.ToString(" #0.00000;-#0.00000"));
            MathDisplay.WriteLine();

            // 3. Generate 10 samples of the Poisson distribution
            MathDisplay.WriteLine(@"3. Generate 10 samples of the Poisson distribution");
            for (var i = 0; i < 10; i++)
            {
                MathDisplay.Write(poisson.Sample().ToString("N05") + @" ");
            }
            MathDisplay.FlushBuffer();
            MathDisplay.WriteLine();
            MathDisplay.WriteLine();


            // <a href="http://en.wikipedia.org/wiki/Zipf_distribution">Zipf distribution</a>
            MathDisplay.WriteLine("<b>Zipf distribution</b>");
            // 1. Initialize the new instance of the Zipf distribution class with parameters S = 5, N = 10
            var zipf = new Zipf(5, 10);

            MathDisplay.WriteLine(@"1. Initialize the new instance of the Zipf distribution class with parameters S = {0}, N = {1}", zipf.S, zipf.N);
            MathDisplay.WriteLine();

            // 2. Distributuion properties:
            MathDisplay.WriteLine(@"2. {0} distributuion properties:", zipf);

            // Cumulative distribution function
            MathDisplay.WriteLine(@"{0} - Сumulative distribution at location '3'", zipf.CumulativeDistribution(3).ToString(" #0.00000;-#0.00000"));

            // Probability density
            MathDisplay.WriteLine(@"{0} - Probability mass at location '3'", zipf.Probability(3).ToString(" #0.00000;-#0.00000"));

            // Log probability density
            MathDisplay.WriteLine(@"{0} - Log probability mass at location '3'", zipf.ProbabilityLn(3).ToString(" #0.00000;-#0.00000"));

            // Entropy
            MathDisplay.WriteLine(@"{0} - Entropy", zipf.Entropy.ToString(" #0.00000;-#0.00000"));

            // Largest element in the domain
            MathDisplay.WriteLine(@"{0} - Largest element in the domain", zipf.Maximum.ToString(" #0.00000;-#0.00000"));

            // Smallest element in the domain
            MathDisplay.WriteLine(@"{0} - Smallest element in the domain", zipf.Minimum.ToString(" #0.00000;-#0.00000"));

            // Mean
            MathDisplay.WriteLine(@"{0} - Mean", zipf.Mean.ToString(" #0.00000;-#0.00000"));

            // Mode
            MathDisplay.WriteLine(@"{0} - Mode", zipf.Mode.ToString(" #0.00000;-#0.00000"));

            // Variance
            MathDisplay.WriteLine(@"{0} - Variance", zipf.Variance.ToString(" #0.00000;-#0.00000"));

            // Standard deviation
            MathDisplay.WriteLine(@"{0} - Standard deviation", zipf.StdDev.ToString(" #0.00000;-#0.00000"));

            // Skewness
            MathDisplay.WriteLine(@"{0} - Skewness", zipf.Skewness.ToString(" #0.00000;-#0.00000"));
            MathDisplay.WriteLine();

            // 3. Generate 10 samples of the Zipf distribution
            MathDisplay.WriteLine(@"3. Generate 10 samples of the Zipf distribution");
            for (var i = 0; i < 10; i++)
            {
                MathDisplay.Write(zipf.Sample().ToString("N05") + @" ");
            }
            MathDisplay.FlushBuffer();
            MathDisplay.WriteLine();
            MathDisplay.WriteLine();
        }
 public void CategoricalCreateFailsWithNegativeRatios()
 {
     var m = new Categorical(badP);
 }
 public void CategoricalCreateFailsWithNullHistogram()
 {
     Histogram h = null;
     var m = new Categorical(h);
 }
 public void SetProbabilityFails()
 {
     var b = new Categorical(largeP);
     b.P = badP;
 }
Beispiel #36
0
        public void CanSample()
        {
            var n = new Categorical(_largeP);

            n.Sample();
        }
 public void CanCreateCategorical()
 {
     var m = new Categorical(largeP);
 }
 public void CanSample()
 {
     var n = new Categorical(_largeP);
     n.Sample();
 }
 public void CategoricalCreateFailsWithAllZeroRatios()
 {
     var m = new Categorical(badP2);
 }
 public void ValidateToString()
 {
     var b = new Categorical(_smallP);
     Assert.AreEqual("Categorical(Dimension = 3)", b.ToString());
 }
 public void CanSample()
 {
     var n = new Categorical(largeP);
     var d = n.Sample();
 }
 public void CanSetProbability()
 {
     var b = new Categorical(largeP);
     b.P = smallP;
 }