List of usage examples for org.apache.commons.math3.linear BlockRealMatrix setEntry
@Override public void setEntry(final int row, final int column, final double value) throws OutOfRangeException
From source file:gamlss.algorithm.Gamlss.java
/** * Main method./*from w w w. ja v a2s. c o m*/ * @param args - command-line arguments */ public static void main(final String[] args) { //String fileName = "Data/dataReduced.csv"; String fileName = "Data/oil.csv"; // String fileName = "Data/sp.csv"; //String fileName = "Data/dataReduced.csv"; CSVFileReader readData = new CSVFileReader(fileName); readData.readFile(); ArrayList<String> data = readData.storeValues; ArrayRealVector y = new ArrayRealVector(data.size()); BlockRealMatrix muX = new BlockRealMatrix(data.size(), 1); BlockRealMatrix sigmaX = new BlockRealMatrix(data.size(), 1); BlockRealMatrix nuX = new BlockRealMatrix(data.size(), 1); BlockRealMatrix tauX = new BlockRealMatrix(data.size(), 1); ArrayRealVector w = new ArrayRealVector(data.size()); BlockRealMatrix muS = new BlockRealMatrix(data.size(), 1); BlockRealMatrix sigmaS = new BlockRealMatrix(data.size(), 1); BlockRealMatrix nuS = new BlockRealMatrix(data.size(), 1); BlockRealMatrix tauS = new BlockRealMatrix(data.size(), 1); for (int i = 0; i < data.size(); i++) { String[] line = data.get(i).split(","); y.setEntry(i, Double.parseDouble(line[0])); muX.setEntry(i, 0, Double.parseDouble(line[1])); muS.setEntry(i, 0, Double.parseDouble(line[1])); sigmaX.setEntry(i, 0, Double.parseDouble(line[1])); sigmaS.setEntry(i, 0, Double.parseDouble(line[1])); nuX.setEntry(i, 0, Double.parseDouble(line[1])); nuS.setEntry(i, 0, Double.parseDouble(line[1])); tauX.setEntry(i, 0, Double.parseDouble(line[1])); tauS.setEntry(i, 0, Double.parseDouble(line[1])); } Hashtable<Integer, BlockRealMatrix> designMatrices = new Hashtable<Integer, BlockRealMatrix>(); designMatrices.put(DistributionSettings.MU, muX); designMatrices.put(DistributionSettings.SIGMA, sigmaX); designMatrices.put(DistributionSettings.NU, nuX); designMatrices.put(DistributionSettings.TAU, tauX); HashMap<Integer, BlockRealMatrix> smoothMatrices = new HashMap<Integer, BlockRealMatrix>(); smoothMatrices.put(DistributionSettings.MU, muS); smoothMatrices.put(DistributionSettings.SIGMA, sigmaS); smoothMatrices.put(DistributionSettings.NU, nuS); smoothMatrices.put(DistributionSettings.TAU, tauS); //smoothMatrices.put(DistributionSettings.MU, null); //smoothMatrices.put(DistributionSettings.SIGMA, null); //smoothMatrices.put(DistributionSettings.NU, null); //smoothMatrices.put(DistributionSettings.TAU, null); DistributionSettings.DISTR = DistributionSettings.SST; Controls.GLOB_DEVIANCE_TOL = 5500; Controls.INTER = 50;//only for the PB smoother Controls.SMOOTHER = Controls.PB; //or PB Controls.IS_SVD = true; Controls.BIG_DATA = true; Controls.JAVA_OPTIMIZATION = false; Controls.GAMLSS_NUM_CYCLES = 50; //Gamlss gamlss = new Gamlss(y, designMatrices, null); Gamlss gamlss = new Gamlss(y, designMatrices, null); //Gamlss gamlss = new Gamlss(y, null, smoothMatrices); gamlss.saveFittedDistributionParameters("Data/oilresults.csv"); }
From source file:gamlss.utilities.MatrixFunctions.java
/** * Build intercept matrix of dimension dim * @param dim - number of rows of intercept matrix * @return intercept matrix //from w w w .ja va2 s .co m */ public static BlockRealMatrix buildInterceptMatrix(int dim) { BlockRealMatrix designMatrix = new BlockRealMatrix(dim, 1); for (int i = 0; i < dim; i++) { designMatrix.setEntry(i, 0, 1.0); } return designMatrix; }
From source file:gamlss.utilities.MatrixFunctions.java
/** * Create a matrix with length of y number of rows * and one column, all entries of the matrix are 1. * @param y - vector /*from w w w . ja v a2 s . c o m*/ * @return matrix */ public static BlockRealMatrix setInterceptMatrix(final ArrayRealVector y) { BlockRealMatrix designMatrix = new BlockRealMatrix(y.getDimension(), 1); for (int i = 0; i < y.getDimension(); i++) { designMatrix.setEntry(i, 0, 1.0); } return designMatrix; }