public static double mad(final double[] data){
  double mad=0;
  if (data.length > 0) {
    double median=median(data);
    double[] deviationSum=new double[data.length];
    for (int i=0; i < data.length; i++) {
      deviationSum[i]=Math.abs(median - data[i]);
    }
    mad=median(deviationSum);
  }
  return mad;
}

public static double mad ( final double [ ] data ) { double mad = 0 ; if ( data . length > 0 ) { double median = median ( data ) ; double [ ] deviationSum = new double [ data . length ] ; for ( int i = 0 ; i < data . length ; i ++ ) { deviationSum [ i ] = Math . abs ( median - data [ i ] ) ; } mad = median ( deviationSum ) ; } return mad ; }
gets the median absolute deviation ( mad ) from a array of numbers .
