Ejemplo n.º 1
0
        public static Vector Rand(int n)
        {
            double[] x = new double[n];
            for (int i = 0; i < n; i++)
            {
                x[i] = MLRandom.GetUniform();
            }

            return(new Vector(x));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Generate a matrix n x d with numbers
        /// 0 &lt; x &lt 1 drawn uniformly at
        /// random
        /// </summary>
        /// <param name="n">rows</param>
        /// <param name="d">cols</param>
        /// <returns>n x d Matrix</returns>
        public static Matrix Rand(int n, int d, int min = 0)
        {
            var m = new double[n][];

            for (int i = 0; i < n; i++)
            {
                m[i] = new double[d];
                for (int j = 0; j < d; j++)
                {
                    m[i][j] = MLRandom.GetUniform() + min;
                }
            }

            return(new Matrix {
                _matrix = m, _asTransposeRef = false, Cols = d, Rows = n
            });
        }