/** * <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 setGaussian( D1Matrix64F mat , double mean , double stdev , Random rand ) { double d[] = mat.getData(); int size = mat.getNumElements(); for( int i = 0; i < size; i++ ) { d[i] = mean + stdev*rand.nextGaussian(); } }
/** * <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 setRandom( D1Matrix64F mat , double min , double max , Random 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; } }
/** * <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 setRandom( D1Matrix64F mat , double min , double max , Random 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; } }
/** * <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 setRandom( D1Matrix64F mat , double min , double max , Random 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; } }
private double[] computeFittedValues() { D1Matrix64F fitted = new DenseMatrix64F(response.length, 1); MatrixVectorMult.mult(X, b, fitted); return fitted.getData(); }