Encog.MathUtil.Matrices.Matrix.Ramdomize C# (CSharp) Method

Ramdomize() public method

Fill the matrix with random values in the specified range.
public Ramdomize ( double min, double max ) : void
min double The minimum value for the random numbers.
max double The maximum value for the random numbers.
return void
        public void Ramdomize(double min, double max)
        {
            for (int r = 0; r < Rows; r++)
            {
                for (int c = 0; c < Cols; c++)
                {
                    matrix[r][c] = (ThreadSafeRandom.NextDouble()*(max - min)) + min;
                }
            }
        }

Usage Example

Example #1
0
        public void Randomize()
        {
            const double min    = 1.0;
            const double max    = 10.0;
            var          matrix = new Matrix(10, 10);

            matrix.Ramdomize(min, max);
            var array = matrix.ToPackedArray();

            foreach (double t in array)
            {
                if (t < min || t > max)
                {
                    Assert.IsFalse(true);
                }
            }
        }
All Usage Examples Of Encog.MathUtil.Matrices.Matrix::Ramdomize