private List<Double> gaussianSmoothing(List<Double> list) {
        
        int n = list.size();
        
        double std = Descriptives.std(new FlatDataCollection((List)list), false);
        double variance = std*std;
        
        int sygma = (int)Math.min(Math.ceil(std), (n-1.0)/2.0);
        
        
        List<Double> gaussianKernel = new ArrayList<>(2*sygma+1);
        double normalizer = 0.0;
        for(int i =0;i<=2*sygma;++i) {
            double value = 0.0;
            for(int j=-sygma;j<=sygma;++j) {
                value += Math.exp((-j*j)/(2.0*variance));
            }
            
            gaussianKernel.add(value);
            
            normalizer += value;//sum of all kernel values
        }
        
        //normalize the kernel
        for(int i =0;i<=2*sygma;++i) {
            gaussianKernel.set(i, gaussianKernel.get(i)/normalizer);
        }
        
        
        List<Double> smoothedList = new ArrayList<>(n); //calculate Gaussian Kernel
        for(int i=0;i<n;++i) {
            double smoothedValue = 0.0;
            for(int j=-sygma;j<=sygma;++j) {
                int index = i-j;
                if(index>=0 && index<n) {
                    smoothedValue+=gaussianKernel.get(j+sygma)*list.get(index);//apply the kernel to the original values
                }
            }
            smoothedList.add(smoothedValue);
        }
        
        
        return smoothedList;
    }
private List < Double > gaussianSmoothing ( List < Double > list ) { int n = list . size ( ) ; double std = Descriptives . std ( new FlatDataCollection ( ( List ) list ) , false ) ; double variance = std * std ; int sygma = ( int ) Math . min ( Math . ceil ( std ) , ( n - 1.0 ) / 2.0 ) ; List < Double > gaussianKernel = new ArrayList < > ( 2 * sygma + 1 ) ; double normalizer = 0.0 ; for ( int i = 0 ; i <= 2 * sygma ; ++ i ) { double value = 0.0 ; for ( int j = - sygma ; j <= sygma ; ++ j ) { value += Math . exp ( ( - j * j ) / ( 2.0 * variance ) ) ; } gaussianKernel . add ( value ) ; normalizer += value ; } for ( int i = 0 ; i <= 2 * sygma ; ++ i ) { gaussianKernel . set ( i , gaussianKernel . get ( i ) / normalizer ) ; } List < Double > smoothedList = new ArrayList < > ( n ) ; for ( int i = 0 ; i < n ; ++ i ) { double smoothedValue = 0.0 ; for ( int j = - sygma ; j <= sygma ; ++ j ) { int index = i - j ; if ( index >= 0 && index < n ) { smoothedValue += gaussianKernel . get ( j + sygma ) * list . get ( index ) ; } } smoothedList . add ( smoothedValue ) ; } return smoothedList ; }
/*
private List<Double> movingAverageSmoothing(List<Double> list, int smoothingAverageRadius) {
int n = list.size();
List<Double> smoothedList = new ArrayList<>(n);

for(int idRow =0;idRow<n;++idRow) {
apply a window based on 2*radius+1
int from = Math.max(idRow-smoothingAverageRadius, 0);
int to = Math.min(idRow+smoothingAverageRadius, n);

double sum = 0.0;
for(int i = from; i<to ; ++i) {
sum+=list.get(i);
}

smoothedList.add(sum/(to-from)); //simple moving average
}

return smoothedList;
}