public static List<MutableDoubleTuple> standardize(
        Collection<? extends DoubleTuple> inputs,
        List<MutableDoubleTuple> results)
    {
        results = validate(inputs, results);
        MutableDoubleTuple mean = arithmeticMean(inputs, null);
        MutableDoubleTuple standardDeviation =
            standardDeviationFromMean(inputs, mean, null);
        int index = 0;

        for (DoubleTuple input : inputs)
        {
            MutableDoubleTuple result = results.get(index);
            DoubleTuples.subtract(input, mean, result);
            DoubleTuples.divide(result, standardDeviation, result);
            index++;
        }

        boolean printResults = false;
        //printResults = true;
        if (printResults)
        {
            MutableDoubleTuple newMean = arithmeticMean(results, null);
            MutableDoubleTuple newStandardDeviation =
                standardDeviationFromMean(results, newMean, null);
            DoubleTuple min = min(results, null);
            DoubleTuple max = max(results, null);
            System.out.println("After standardization:");
            System.out.println("mean              : "+newMean);
            System.out.println("standard deviation: "+newStandardDeviation);
            System.out.println("min               : "+min);
            System.out.println("max               : "+max);
        }

        return results;
    }
public static List < MutableDoubleTuple > standardize ( Collection < ? extends DoubleTuple > inputs , List < MutableDoubleTuple > results ) { results = validate ( inputs , results ) ; MutableDoubleTuple mean = arithmeticMean ( inputs , null ) ; MutableDoubleTuple standardDeviation = standardDeviationFromMean ( inputs , mean , null ) ; int index = 0 ; for ( DoubleTuple input : inputs ) { MutableDoubleTuple result = results . get ( index ) ; DoubleTuples . subtract ( input , mean , result ) ; DoubleTuples . divide ( result , standardDeviation , result ) ; index ++ ; } boolean printResults = false ; if ( printResults ) { MutableDoubleTuple newMean = arithmeticMean ( results , null ) ; MutableDoubleTuple newStandardDeviation = standardDeviationFromMean ( results , newMean , null ) ; DoubleTuple min = min ( results , null ) ; DoubleTuple max = max ( results , null ) ; System . out . println ( "After standardization:" ) ; System . out . println ( "mean              : " + newMean ) ; System . out . println ( "standard deviation: " + newStandardDeviation ) ; System . out . println ( "min               : " + min ) ; System . out . println ( "max               : " + max ) ; } return results ; }
Standardize the given input tuples. This means that the mean of
the given tuples is subtracted from them, and they are divided
by the standard deviation. <br>
<br>
The results will be written into the given result tuples.
If the given results list is <code>null</code>, then a new
list will be created and returned. <br>
<br>
If the result list is not <code>null</code>, then it must have the
same size as the input collection, otherwise an
<code>IllegalArgumentException</code> will be thrown.<br>
<br>
If the input collection contains <code>null</code> elements, then a
<code>NullPointerException</code> will be thrown. <br>
<br>
If the result list contains <code>null</code> elements, then a
<code>NullPointerException</code> will be thrown. <br>
<br>
The input collection and the results list may contain
pairwise identical elements.<br>
<br>
The input collection and the results list may be identical.
<br>
@param inputs The input tuples
@param results The result tuples
@return The result tuples
@throws IllegalArgumentException If the result list is not
<code>null</code> and has a size that is different from the size
of the input collection
@throws NullPointerException If the inputs list is <code>null</code>
or contains <code>null</code> elements, or if the output list is
non-<code>null</code> and contains <code>null</code> elements