コード例 #1
0
        /// <summary>
        /// Generate random data.
        /// </summary>
        /// <param name="seed">The seed to use.</param>
        /// <param name="rows">The number of rows to generate.</param>
        /// <param name="cols">The number of columns to generate.</param>
        /// <param name="low">The low value.</param>
        /// <param name="high">The high value.</param>
        /// <param name="distort">The distortion factor.</param>
        /// <returns>The data set.</returns>
        public DataHolder Generate(int seed, int rows, int cols, double low,
            double high, double distort)
        {
            IGenerateRandom rnd = new MersenneTwisterGenerateRandom((uint)seed);

            var ideal = new double[rows][];
            var actual = new double[rows][];

            for (int row = 0; row < rows; row++)
            {
                for (int col = 0; col < cols; col++)
                {
                    ideal[row] = new double[cols];
                    actual[row] = new double[cols];
                    ideal[row][col] = rnd.NextDouble(low, high);
                    actual[row][col] = ideal[row][col] + (rnd.NextGaussian() * distort);
                }
            }

            var result = new DataHolder {Actual = actual, Ideal = ideal};
            return result;
        }
コード例 #2
0
 public void TestGaussianFloat()
 {
     var rnd = new MersenneTwisterGenerateRandom(1);
     foreach (double aGaussianTest in GaussianTest)
     {
         double g = rnd.NextGaussian();
         Assert.AreEqual(g, aGaussianTest, AIFH.DefaultPrecision);
     }
 }