示例#1
0
        /**
         * <p>
         * Sets each element in the matrix to a value drawn from an Gaussian distribution with the specified mean and
         * standard deviation
         * </p>
         *
         * @param mat The matrix who is to be randomized. Modified.
         * @param mean Mean value in the distribution
         * @param stdev Standard deviation in the distribution
         * @param rand Random number generator used to fill the matrix.
         */
        public static void fillGaussian(DMatrixD1 mat, double mean, double stdev, IMersenneTwister rand)
        {
            double[] d    = mat.getData();
            int      size = mat.getNumElements();

            for (int i = 0; i < size; i++)
            {
                d[i] = mean + stdev * (double)rand.NextGaussian();
            }
        }
示例#2
0
        /**
         * <p>
         * Sets each element in the matrix to a value drawn from an Gaussian distribution with the specified mean and
         * standard deviation
         * </p>
         *
         * @param mat The matrix who is to be randomized. Modified.
         * @param mean Mean value in the distribution
         * @param stdev Standard deviation in the distribution
         * @param randJava.Util.Random number generator used to fill the matrix.
         */
        public static void fillGaussian(DMatrixD1 mat, double mean, double stdev, Java.Util.Random rand)
        {
            double[] d    = mat.getData();
            int      size = mat.NumElements;

            Java.Util.Random random2 = new Java.Util.Random();
            for (int i = 0; i < size; i++)
            {
                d[i] = mean + stdev * (double)random2.NextGaussian();
            }
        }
示例#3
0
        /**
         * <p>
         * Sets each element in the matrix to a value drawn from an uniform distribution from 'min' to 'max' inclusive.
         * </p>
         *
         * @param min The minimum value each element can be.
         * @param max The maximum value each element can be.
         * @param mat The matrix who is to be randomized. Modified.
         * @param randJava.Util.Random number generator used to fill the matrix.
         */
        public static void fillUniform(DMatrixD1 mat, double min, double max, Java.Util.Random rand)
        {
            double[] d    = mat.getData();
            int      size = mat.NumElements;

            double r = max - min;

            for (int i = 0; i < size; i++)
            {
                d[i] = r * rand.NextDouble() + min;
            }
        }
示例#4
0
        /**
         * <p>
         * Sets each element in the matrix to a value drawn from an uniform distribution from 'min' to 'max' inclusive.
         * </p>
         *
         * @param min The minimum value each element can be.
         * @param max The maximum value each element can be.
         * @param mat The matrix who is to be randomized. Modified.
         * @param rand Random number generator used to fill the matrix.
         */
        public static void fillUniform(DMatrixD1 mat, double min, double max, IMersenneTwister rand)
        {
            double[] d    = mat.getData();
            int      size = mat.getNumElements();

            double r = max - min;

            for (int i = 0; i < size; i++)
            {
                d[i] = r * rand.NextDouble() + min;
            }
        }