Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProbabilityDistribution"/> class.
        /// </summary>
        /// <param name="weights">The probabilities of possible outcomes.</param>
        /// <param name="random">The random number generator.</param>
        public ProbabilityDistribution(IList <float> weights, Random random)
        {
            if (weights == null)
            {
                throw new ArgumentNullException(nameof(weights));
            }

            this.random = new RandomGeneratorF(random);

            this.pdf = weights.ToArray();
            float sum = Vectors.CumulativeSum(this.pdf.Length, this.pdf, 0);

            if (sum != 0.0f)
            {
                Mathematics.DivC(this.pdf.Length, sum, this.pdf, 0);
            }
        }
Esempio n. 2
0
 public void DivC(float alpha) => Mathematics.DivC(this.Idx.Length, alpha, this.X, 0);
Esempio n. 3
0
 public void AddProductC(float alpha, float[] y, int offy) => Mathematics.AddProductC(this.length, this.x, this.offset, alpha, y, offy);
Esempio n. 4
0
 public void DivC(float alpha) => Mathematics.DivC(this.length, alpha, this.x, this.offset);
Esempio n. 5
0
 public void MulC(float alpha) => Mathematics.MulC(this.x.Length, alpha, this.x, 0);