Correlation experiments. Construct a test-input with 6000 samples of Gold26, find the match-point and use 1/4 chips spacing

public void fillArray13()
    {
    	// correlation experiments
    	// construct a test-input with 6000 samples of Gold26
    	// find the match-point
    	// now use 1/4 chips spacing
    	
    	int shift = 3600; // display only most interesting part
    	int inplen = 6000;
    	int[] testinput = new int[inplen];
    	int[] bins = new int[inplen];
    	
    	System.out.println("experiment 13. Correlation 1/4 chips spacing");
    	
    	GoldSequence gold26 = new GoldSequence(2,6);

    	// throw away first 35 chips
    	for (int i = 0; i < 35; i++)
    	{
    		gold26.nextan4();
    	}
    	
    	for (int i = 0; i < testinput.length; i++)
    	{
    		testinput[i] = gold26.nextan4();
    	}
    	
    	gold26.reset();
    	
    	// this is an implimentation of a correlator
    	
    	for (int i = 0; i < inplen; i++)
    	{
    		gold26.reset();
    		int acc = 0;
    		for (int j = 0; j < 1023; j++)
    		{
    			if ((i + j) < inplen)
    			{
    				acc = acc + testinput[i + j] * gold26.nextan4();
    			}
    		}
    		bins[i] = acc;
    	}
    	    	
    	plotData = new double[1268];
    	for(int i=0; i<1268; i++)
    	{
    		plotData[i] = bins[i + shift];
    		System.out.println(i + " " + plotData[i]);
    	}
    } 

And this results in the following beautiful graphic output:

correlation4

Where is the peak? Throw away the first 35 samples. With 1/4 chips spacing there are 4*1023=4092 samples. So after 4092 - 35 = 4057 there will be a peak. With a shift of 3600 the peak in the display is at bin 4057 - 3600 = 457. The triangle shape is clearly visible.

A more sophisticated correlation experiment. Construct a test-input with 6000 samples of Gold26, find the match-point. Now use 1/4 chips spacing and add Gaussian noise. Negative sign of input-PRN

public void fillArray14()
    {
    	// correlation experiments
    	// construct a test-input with 6000 samples of Gold26
    	// find the match-point
    	// now use 1/4 chips spacing
    	// and add Gaussian noise
    	// negative sign of input-PRN
    	
    	int shift = 3600; // display only most interesting part
    	int inplen = 6000;
    	double[] testinput = new double[inplen];
    	double[] bins = new double[inplen];
    	Random r = new Random();
    	int noise = 5;
    	int sign = -1;
    	
    	System.out.println("experiment 14. Correlation 1/4 chips spacing" +
    			" and Gaussian noise added");
    	
    	GoldSequence gold26 = new GoldSequence(2,6);

    	// throw away first 35 chips
    	for (int i = 0; i < 35; i++)
    	{
    		gold26.nextan4();
    	}
    	
    	for (int i = 0; i < testinput.length; i++)
    	{
    		testinput[i] = sign * gold26.nextan4() + noise * r.nextGaussian();
    	}
    	
    	gold26.reset();
    	
    	// this is an implimentation of a correlator
    	
    	for (int i = 0; i < inplen; i++)
    	{
    		gold26.reset();
    		double acc = 0;
    		for (int j = 0; j < 1023; j++)
    		{
    			if ((i + j) < inplen)
    			{
    				acc = acc + testinput[i + j] * gold26.nextan4();
    			}
    		}
    		bins[i] = acc;
    	}
    	    	
    	plotData = new double[1268];
    	for(int i=0; i<1268; i++)
    	{
    		plotData[i] = bins[i + shift];
    		System.out.println(i + " " + plotData[i]);
    	}
    } 

The corresponding output is:

correlationGauss

The peak is, again, at bin 457. The program is in fact the same as the previous example