@@ -0,0 +1,2577 @@
+package greycat.ml.math.periodicity;%0A%0Aimport greycat.utility.distance.Distance;%0Aimport greycat.utility.distance.PearsonDistance;%0A%0A/**%0A * Created by assaad on 08/03/2017.%0A */%0Apublic class PearsonPeriodicity %7B%0A%0A%0A    private static double sumup(double%5B%5D dataInput, int estimatedPer, int offset) %7B%0A        double sum = 0;%0A        for (int i = 0; i %3C dataInput.length; i++) %7B%0A            if (i %25 estimatedPer == offset) %7B%0A                sum = sum + dataInput%5Bi%5D;%0A            %7D%0A        %7D%0A        return sum;%0A    %7D%0A%0A    private static double getAverage (double%5B%5D values) %7B%0A        double sum = 0;%0A        for (int i = 0; i %3Cvalues.length;i++) %7B%0A            sum = sum + values%5Bi%5D;%0A        %7D%0A        return sum/values.length;%0A    %7D%0A%0A    public static int getPeriod(double%5B%5D values, int minSearch, int maxSearch) %7B%0A%0A        //this value is used to compute the confidence at the end%0A        double sumPearsonCorr = 0;%0A%0A        int max=0;%0A        double value=-1;%0A        Distance pearsonDist= PearsonDistance.instance();%0A%0A        for(int estimPer = minSearch; estimPer %3C= maxSearch; estimPer++)%7B%0A            double%5B%5D sumResults = new double%5BestimPer%5D;%0A%0A            for(int offSet = 0; offSet %3C= estimPer-1; offSet++)%7B%0A                double currentSum = sumup(values, estimPer, offSet);%0A                sumResults%5BoffSet%5D=currentSum;%0A            %7D%0A%0A            //now we got the sums for one estimated period (this is called component with length sumResults.length()), now compare this componends with parts of the origninal curve%0A%0A            int numberOfSwaps = values.length/sumResults.length;%0A            int offset = 0;%0A            double%5B%5D pearson = new double%5BnumberOfSwaps%5D;%0A            for(int swap = 0; swap %3C numberOfSwaps; swap++) %7B%0A%0A                //now cut parts from the current observation and correlate it with the component%0A                double%5B%5D currentOrigComponent = new double%5BsumResults.length%5D;%0A                System.arraycopy(values, offset, currentOrigComponent, 0, sumResults.length);%0A                offset = offset + sumResults.length;%0A%0A                pearson%5Bswap%5D=pearsonDist.measure(currentOrigComponent, sumResults);%0A            %7D%0A%0A            //now all parts of the observation curve have been correlated with the component%0A            //now we have to get the average of the pearson correlations%0A            double avgPearson = getAverage(pearson);%0A            if(avgPearson%3Evalue)%7B%0A                value=avgPearson;%0A                max=estimPer;%0A            %7D%0A%0A        %7D%0A        return max;%0A    %7D%0A%0A    public static double convert(int position)%0A%7D%0A

Add pearson periodicity detection