private void calcStats(){
  double[] data=null;
  int tot=0;
  SynapseView type=(SynapseView)synTypeSelector.getSelectedItem();
  double runningVal=0;
  if (weights[0].length == 0 && weights[1].length == 0) {
    return;
  }
  if (type.equals(SynapseView.ALL)) {
    tot=weights[0].length + weights[1].length;
    data=new double[tot];
    int c=0;
    for (int i=0; i < 2; i++) {
      for (int j=0, m=weights[i].length; j < m; j++) {
        double val=weights[i][j];
        runningVal+=val;
        data[c]=val;
        c++;
      }
    }
  }
 else   if (type.equals(SynapseView.OVERLAY)) {
    tot=weights[0].length + weights[1].length;
    data=new double[tot];
    int c=0;
    for (int i=0; i < 2; i++) {
      for (int j=0, m=weights[i].length; j < m; j++) {
        double val=Math.abs(weights[i][j]);
        runningVal+=val;
        data[c]=val;
        c++;
      }
    }
  }
 else   if (type.equals(SynapseView.EXCITATORY) && weights[0].length != 0) {
    tot=weights[0].length;
    data=new double[tot];
    for (int j=0; j < tot; j++) {
      double val=Math.abs(weights[0][j]);
      runningVal+=val;
      data[j]=val;
    }
  }
 else   if (type.equals(SynapseView.INHIBITORY) && weights[1].length != 0) {
    tot=weights[1].length;
    data=new double[tot];
    for (int j=0; j < tot; j++) {
      double val=weights[1][j];
      runningVal+=val;
      data[j]=val;
    }
  }
  if (data != null) {
    mean=runningVal / tot;
    Arrays.sort(data);
    if (tot % 2 == 0) {
      median=(data[tot / 2] + data[(tot / 2) - 1]) / 2;
    }
 else {
      median=data[(int)Math.floor(tot / 2)];
    }
    runningVal=0;
    for (int i=0; i < tot; i++) {
      runningVal+=Math.pow((mean - data[i]),2);
    }
    runningVal=runningVal / tot;
    stdDev=Math.sqrt(runningVal);
  }
}

private void calcStats ( ) { double [ ] data = null ; int tot = 0 ; SynapseView type = ( SynapseView ) synTypeSelector . getSelectedItem ( ) ; double runningVal = 0 ; if ( weights [ 0 ] . length == 0 && weights [ 1 ] . length == 0 ) { return ; } if ( type . equals ( SynapseView . ALL ) ) { tot = weights [ 0 ] . length + weights [ 1 ] . length ; data = new double [ tot ] ; int c = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 , m = weights [ i ] . length ; j < m ; j ++ ) { double val = weights [ i ] [ j ] ; runningVal += val ; data [ c ] = val ; c ++ ; } } } else if ( type . equals ( SynapseView . OVERLAY ) ) { tot = weights [ 0 ] . length + weights [ 1 ] . length ; data = new double [ tot ] ; int c = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 , m = weights [ i ] . length ; j < m ; j ++ ) { double val = Math . abs ( weights [ i ] [ j ] ) ; runningVal += val ; data [ c ] = val ; c ++ ; } } } else if ( type . equals ( SynapseView . EXCITATORY ) && weights [ 0 ] . length != 0 ) { tot = weights [ 0 ] . length ; data = new double [ tot ] ; for ( int j = 0 ; j < tot ; j ++ ) { double val = Math . abs ( weights [ 0 ] [ j ] ) ; runningVal += val ; data [ j ] = val ; } } else if ( type . equals ( SynapseView . INHIBITORY ) && weights [ 1 ] . length != 0 ) { tot = weights [ 1 ] . length ; data = new double [ tot ] ; for ( int j = 0 ; j < tot ; j ++ ) { double val = weights [ 1 ] [ j ] ; runningVal += val ; data [ j ] = val ; } } if ( data != null ) { mean = runningVal / tot ; Arrays . sort ( data ) ; if ( tot % 2 == 0 ) { median = ( data [ tot / 2 ] + data [ ( tot / 2 ) - 1 ] ) / 2 ; } else { median = data [ ( int ) Math . floor ( tot / 2 ) ] ; } runningVal = 0 ; for ( int i = 0 ; i < tot ; i ++ ) { runningVal += Math . pow ( ( mean - data [ i ] ) , 2 ) ; } runningVal = runningVal / tot ; stdDev = Math . sqrt ( runningVal ) ; } }
gets the basic statistics : mean , median , and standard deviation of the synapse weights based on which group of synapses is selected .
