Exemple #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));
        }
Exemple #2
0
        public static Vector NormRand(int n, double mean = 0, double stdDev = 1, int precision = -1)
        {
            double[] x = new double[n];
            for (int i = 0; i < n; i++)
            {
                if (precision > -1)
                {
                    x[i] = System.Math.Round(MLRandom.GetNormal(mean, stdDev), precision);
                }
                else
                {
                    x[i] = MLRandom.GetNormal(mean, stdDev);
                }
            }

            return(new Vector(x));
        }
Exemple #3
0
        public static Matrix NormRand(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.GetNormal() + min;
                }
            }

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