package NeuralNet;

import java.util.ArrayList;

/**
 * collection of sample data
 */
public class Data {


    /**
     * List of sample data
     */
    public ArrayList<Sample> SampleList = new ArrayList<>();
    public ErrorTrack errorTrack = new ErrorTrack();

    
    /**
     * add a new sample data
     *
     * @param in array of double with the input data
     * @param test array of double with the expected data
     */
    public void addSample(double[] in, double[] test) {
        Sample sample = new Sample(this);
        sample.inputData = in;
        sample.testData = test;
        sample.outputData = new double[test.length];
        SampleList.add(sample);
    }

   
    /**
     * get the total error of all samples
     *  
     * @return sum of the total error
     */
    public double getDataError() {
        
        
        double t = 0;
        for (Sample sample : SampleList) {
            t = t + sample.sampleRms.getSampletError();
        }
        return t;
    }
    public double getMaxError(){
        double maxErr=0;
    
        for (Sample sample : SampleList) {
            double thisErr= sample.sampleRms.getSampletError();
            if (thisErr>maxErr) {
                maxErr=thisErr;
            }
        }
        return maxErr;
    }
    
}
@@ -109,18 +109,16 @@
 ta %7B%0D%0A%0D%0A
-%0D%0A
     /**%0D
@@ -273,22 +273,16 @@
 k();%0D%0A%0D%0A
-    %0D%0A
     /**%0D
@@ -703,21 +703,16 @@
    %7D%0D%0A%0D%0A
-   %0D%0A
     /**%0D
@@ -761,18 +761,16 @@
 %0D%0A     *
-  
 %0D%0A     *
@@ -847,34 +847,16 @@
 or() %7B%0D%0A
-        %0D%0A        
 %0D%0A      
@@ -1006,24 +1006,26 @@
  t;%0D%0A    %7D%0D%0A
+%0D%0A
     public d
@@ -1043,16 +1043,17 @@
 xError()
+ 
 %7B%0D%0A     
@@ -1072,17 +1072,15 @@
 xErr
-=
+ = 
 0;%0D%0A
-    
 %0D%0A  
@@ -1147,16 +1147,17 @@
  thisErr
+ 
 = sample
@@ -1210,17 +1210,19 @@
 (thisErr
-%3E
+ %3E 
 maxErr) 
@@ -1246,17 +1246,19 @@
   maxErr
-=
+ = 
 thisErr;
@@ -1320,11 +1320,1370 @@
  %7D%0D%0A
+%0D%0A
     
+public void normalizeSamples() %7B%0D%0A%0D%0A        // get max%0D%0A        double maxIn = 0;%0D%0A        double maxOut = 0;%0D%0A%0D%0A        double minIn = 0;%0D%0A        double minOut = 0;%0D%0A%0D%0A        %0D%0A        %0D%0A        %0D%0A        for (int i = 0; i %3C SampleList.size(); i++) %7B%0D%0A%0D%0A            double%5B%5D in = SampleList.get(i).inputData;%0D%0A            double%5B%5D test = SampleList.get(i).testData;%0D%0A            if ((in%5B0%5D %3E maxIn)%7C(i==0)) %7B%0D%0A                maxIn = in%5B0%5D;%0D%0A            %7D%0D%0A            if ((in%5B0%5D %3C minIn)%7C(i==0)) %7B%0D%0A                minIn = in%5B0%5D;%0D%0A            %7D%0D%0A%0D%0A            if ((test%5B0%5D %3E maxOut)%7C%7C(i==0)) %7B%0D%0A                maxOut = test%5B0%5D;%0D%0A            %7D%0D%0A            if ((test%5B0%5D %3C minOut)%7C(i==0)) %7B%0D%0A                minOut = test%5B0%5D;%0D%0A            %7D%0D%0A%0D%0A        %7D%0D%0A%0D%0A        for (int i = 0; i %3C SampleList.size(); i++) %7B%0D%0A            double%5B%5D in = SampleList.get(i).inputData;%0D%0A            double%5B%5D test = SampleList.get(i).testData;%0D%0A            %0D%0A%0D%0A            double%5B%5D normIn = %7BUti.normalize(minIn, maxIn, in%5B0%5D)%7D;%0D%0A            double%5B%5D normTest = %7BUti.normalize(minOut, maxOut, test%5B0%5D)%7D;%0D%0A           %0D%0A%0D%0A            Sample sample = new Sample(this);%0D%0A            sample.inputData = normIn;%0D%0A            sample.testData = normTest;%0D%0A            sample.outputData = new double%5BnormTest.length%5D;%0D%0A            SampleList.set(i, sample);%0D%0A%0D%0A        %7D%0D%0A%0D%0A    %7D%0D%0A%0D%0A%7D
 %0D%0A
-%7D

normalize data