예제 #1
0
        /// <summary>
        /// Метод для генерации последовательнсоти псевдослучайных чисел с учетом номрального распредления
        /// </summary>
        /// <param name="seed">Значение ининциализатора пседвослучайных чисел</param>
        /// <param name="dataCount">Количество генерируемых данных</param>
        /// <returns>Сгенерированный массив</returns>
        public double[] GetNormalDistributionData(int seed, int dataCount)
        {
            var rnd      = new NormalRandom(seed);
            var rndArray = new double[dataCount];

            for (int i = 0; i < rndArray.Length; i++)
            {
                rndArray[i] = rnd.Next(10, 2);
            }

            return(rndArray);
        }
예제 #2
0
        public void CheckOrderStatistics03()
        {
            double mean   = 100;
            double stdDev = 25;

            NormalRandom rand = new NormalRandom(mean, stdDev, new Random());

            double[] values = new double[maxNumbers];
            for (int i = 0; i < maxNumbers; i++)
            {
                values[i] = rand.Next();
            }

            double average = values.Average();

            Assert.AreEqual(mean, average, tolerance * mean);
            double sumOfSquaresOfDifferences = values.Select(val => (val - average) * (val - average)).Sum();
            double sd = Math.Sqrt(sumOfSquaresOfDifferences / values.Length);

            Assert.AreEqual(stdDev, sd, tolerance);
        }
예제 #3
0
파일: RNG.cs 프로젝트: hnjm/sharp-chat
 public static int Next(int min, int max)
 {
     lock (Lock)
         return(NormalRandom.Next(min, max));
 }
예제 #4
0
파일: RNG.cs 프로젝트: hnjm/sharp-chat
 public static int Next()
 {
     lock (Lock)
         return(NormalRandom.Next());
 }