예제 #1
0
        /// <summary>
        ///   Generates a random observation from the current distribution.
        /// </summary>
        ///
        /// <returns>A random observations drawn from this distribution.</returns>
        ///
        public override double Generate()
        {
            // Choose one coefficient at random
            int c = GeneralDiscreteDistribution.Random(coefficients);

            // Sample from the chosen coefficient
            var d = components[c] as ISampleableDistribution <double>;

            if (d == null)
            {
                throw new InvalidOperationException();
            }

            return(d.Generate());
        }