Exemplo n.º 1
0
 public double[] getCumulativeInertia() {
   double tot = 0.0;
   for (double val : ca.getRates()) {
     tot += val;
   }
   double[] p = new double[ca.getRates().length];
   for (int i = 0; i < p.length; i++) {
     p[i] = ca.getRates()[i] / tot;
     if (i > 0) p[i] += p[i - 1];
   }
   return p;
 }
Exemplo n.º 2
0
  public ResultCA(CorrespondenceAnalysis ca, Word[] rowlabs, ConciseDocument[] collabs) {
    this.rowlabs = rowlabs;
    this.collabs = collabs;
    principal = ca.getPrincipalMatrix();
    n = principal.getRowDimension();
    m = principal.getColumnDimension();
    double[][] data = principal.getArray();
    double[] rowmass = principal.getRowMass();
    double[] colmass = principal.getColumnMass();

    double trace = ca.getTrace();

    this.ca = ca;
    int nfactor = Math.min(n, m) - 1;

    // First determine inertias of observations (rows) and
    // variables (columns), and qualities of representation
    // in the new factor space.
    rinertia = new double[n]; // relative inertia
    cinertia = new double[m];
    rquality = new double[n]; // quality
    cquality = new double[m];
    for (int i = 0; i < n; i++) {
      rinertia[i] = 0.0;
      rquality[i] = 0.0;
      for (int j = 0; j < m; j++) {
        rinertia[i] += Math.pow((data[i][j] / rowmass[i] - colmass[j]), 2.0) / colmass[j];
      }
      rinertia[i] = rowmass[i] * rinertia[i] / trace;
      for (int k = 1; k <= nfactor; k++) {
        rquality[i] += ca.getRowCorrelations()[i][k];
      }
    }

    for (int j = 0; j < m; j++) {
      cinertia[j] = 0.0;
      cquality[j] = 0.0;
      for (int i = 0; i < n; i++) {
        cinertia[j] += Math.pow((data[i][j] / colmass[j] - rowmass[i]), 2.0) / rowmass[i];
      }
      cinertia[j] = colmass[j] * cinertia[j] / trace;
      for (int k = 1; k <= nfactor; k++) {
        cquality[j] += ca.getColumnCorrelations()[j][k];
      }
    }
  }
Exemplo n.º 3
0
 public double[][] getRowContributions() {
   return ca.getRowContributions();
 }
Exemplo n.º 4
0
 public double[][] getRowCorrelations() {
   return ca.getRowCorrelations();
 }
Exemplo n.º 5
0
 public double[][] getRowProjections() {
   return ca.getRowProjections();
 }
Exemplo n.º 6
0
 public double getTrace() {
   return ca.getTrace();
 }
Exemplo n.º 7
0
 public double[] getLambda() {
   return ca.getEigenvalues();
 }
Exemplo n.º 8
0
 public double[] getRatesOfInertia() {
   return ca.getRates();
 }
Exemplo n.º 9
0
 public double[][] getColumnContributions() {
   return ca.getColumnContributions();
 }
Exemplo n.º 10
0
 public double[][] getColumnCorrelations() {
   return ca.getColumnCorrelations();
 }
Exemplo n.º 11
0
 public double[][] getColumnProjections() {
   return ca.getColumnProjections();
 }