Ejemplo n.º 1
0
        public void RandomExtenderDistributionAlgorithmNormalTests()
        {
            var           r         = new RandomExtender(1000);
            double        mean      = 0;
            double        deviation = 1;
            uint          ranges    = 10;
            uint          samples   = 1000;
            double        min       = -2.5;
            double        max       = 2.5;
            IList <Range> dist      = GetDistributionForFunction(samples, () => r.NextNormal(mean, deviation), min, max, ranges);

            double certainty = 0.8;

            var    expectedranges = new double[ranges];
            double rangewidth     = (max - min) / ranges;

            for (int i = 0; i < ranges; i++)
            {
                expectedranges[i] = (samples
                                     * IntegrateNormal(min + (i * rangewidth), min + ((i + 1) * rangewidth), mean, deviation));
            }

            for (int i = 0; i < dist.Count; i++)
            {
                Assert.IsTrue(
                    dist[i].HitCount >= expectedranges[i] * certainty && dist[i].HitCount <= expectedranges[i] * (2 - certainty));
            }
        }
Ejemplo n.º 2
0
        public void GenerateTriangularAndTest()
        {
            double        start = 0, end = 20, peak = 5;
            var           r       = new RandomExtender(1044400);
            uint          ranges  = 8;
            uint          samples = 10000;
            IList <Range> dist    = GetDistributionForFunction(samples, () => r.NextTriangular(start, end, peak), start, end, ranges);

            double certainty      = 0.9;
            var    expectedranges = new double[ranges];
            double rangewidth     = (end - start) / ranges;

            // fill to end
            for (int i = 0; i < ranges; i++)
            {
                expectedranges[i] = (samples
                                     * IntegrateTriang(start + (i * rangewidth), start + ((i + 1) * rangewidth), start, end, peak));
            }

            for (int i = 0; i < dist.Count; i++)
            {
                Assert.IsTrue(
                    dist[i].HitCount >= expectedranges[i] * certainty && dist[i].HitCount <= expectedranges[i] * (2 - certainty));
            }
        }
Ejemplo n.º 3
0
        public void RandomExtenderDistributionAlgorithmUniformTests()
        {
            var           r       = new RandomExtender(1000);
            uint          ranges  = 5;
            uint          samples = 10000;
            IList <Range> dist    = GetDistributionForFunction(samples, r.NextUniform, 0, 1, ranges);

            double certainty   = 0.9;
            uint   expectedall = samples / ranges;

            foreach (Range range in dist)
            {
                Assert.IsTrue(range.HitCount > expectedall * certainty && range.HitCount < expectedall * (2 - certainty));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RandomCallGenerator"/> class.
        /// </summary>
        /// <param name="randomSeed">The random seed to use when generating data.</param>
        /// <param name="speedMean">The call travelling speed distribution mean.</param>
        /// <param name="speedDeviation">The call travelling speed distribution deviation.</param>
        /// <param name="interArrivalMean">The mean value of the inter arrival time of calls.</param>
        /// <param name="durationMean">The mean value of the call duration distribution.</param>
        /// <param name="callPosPeak">The peak, or mode, value of the call position distribution</param>
        /// <param name="callPosStart"></param>
        /// <param name="callPosEnd"></param>
        public RandomCallGenerator(
			uint randomSeed,
			double callPosStart,
			double callPosEnd,
			double callPosPeak,
			double speedMean,
			double speedDeviation,
			double interArrivalMean,
			double durationMean )
        {
            _callPosStart = callPosStart;
            _callPosEnd = callPosEnd;
            _callPosPeak = callPosPeak;
            _speedMean = speedMean;
            _speedDeviation = speedDeviation;
            _interArrivalMean = interArrivalMean;
            _durationMean = durationMean;
            _random = new RandomExtender( randomSeed );
        }