/**
   * sdf The test main
   *
   * @param args ignored
   */
  public static void main(String[] args) {
    //        Instance[] instances =  new Instance[100];
    //        for (int i = 0; i < instances.length; i++) {
    //            double[] data = new double[2];
    //            data[0] = Math.sin(i/2.0);
    //            data[1] = (Math.random() - .5)*2;
    //            instances[i] = new Instance(data);
    //        }
    DataSet set = new DataSet(trainInstances);
    System.out.println("Before randomizing");
    System.out.println(set);
    //        Matrix projection = new RectangularMatrix(new double[][]{ {.6, .6}, {.4, .6}});
    Matrix projection = new RectangularMatrix(new double[][] {{.1, .1}, {.1, .1}});

    for (int i = 0; i < set.size(); i++) {
      Instance instance = set.get(i);
      instance.setData(projection.times(instance.getData()));
    }
    System.out.println("Before ICA");
    System.out.println(set);
    IndependentComponentAnalysis filter = new IndependentComponentAnalysis(set, 1);
    filter.filter(set);
    System.out.println("After ICA");
    System.out.println(set);
  }
Exemplo n.º 2
0
 /**
  * Set a block in this matrix equal to the given matrix
  *
  * @param i the top row of the block
  * @param j the left most column of the block
  * @param matrix the values to set the block with
  */
 public void set(int i, int j, Matrix matrix) {
   for (int row = i; row < matrix.m() + i; row++) {
     for (int column = j; column < matrix.n() + j; column++) {
       set(row, column, matrix.get(row - i, column - j));
     }
   }
 }
Exemplo n.º 3
0
 /**
  * Multiply this matrix with another matrix
  *
  * @param matrix the other matrix
  * @return the resulting matrix
  */
 public Matrix times(Matrix matrix) {
   double[][] result = new double[m()][matrix.n()];
   for (int row = 0; row < result.length; row++) {
     for (int column = 0; column < result[0].length; column++) {
       for (int i = 0; i < n(); i++) {
         result[row][column] += get(row, i) * matrix.get(i, column);
       }
     }
   }
   return new RectangularMatrix(result);
 }
Exemplo n.º 4
0
 /**
  * Subtract from this matrix in place
  *
  * @param matrix the matrix to subtract
  */
 public void minusEquals(Matrix matrix) {
   for (int i = 0; i < m(); i++) {
     for (int j = 0; j < n(); j++) {
       set(i, j, get(i, j) - matrix.get(i, j));
     }
   }
 }
Exemplo n.º 5
0
 /**
  * Subtract this matrix with another matrix
  *
  * @param matrix the other matrix
  * @return the resulting matrix
  */
 public Matrix minus(Matrix matrix) {
   double[][] result = new double[m()][n()];
   for (int i = 0; i < result.length; i++) {
     for (int j = 0; j < result[i].length; j++) {
       result[i][j] = get(i, j) - matrix.get(i, j);
     }
   }
   return new RectangularMatrix(result);
 }
Exemplo n.º 6
0
 /**
  * Multiply the matrix by a scale
  *
  * @param scale the scale
  * @return the scaled matrix
  */
 public Matrix times(double scale) {
   Matrix result = (Matrix) copy();
   result.timesEquals(scale);
   return result;
 }