import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import au.com.bytecode.opencsv.CSVReader;

public class Sensor {

	private long[] times;
	private double[] bearings;

	public Sensor(final String path) throws IOException {

		DateTimeFormatter formatter = DateTimeFormat
				.forPattern("yyMMdd HHmmss");

		// schema
		// 100112 120000,12000.00 ,24000.00 ,0.00 ,-153.43 

		// Reading the csv file but ignoring the first column since it contains
		// headings the result is stored in a list
		CSVReader csvReader = null;

		try {
			csvReader = new CSVReader(new FileReader(path), ',', '\'', 1);
			final List<String[]> content = csvReader.readAll();
			// variable to hold each row of the List while iterating through it
			String[] row = null;

			// counter used to populate the variables with data from the csv
			// file
			int counter = 0;

			// initializing the variables to hold data in the csv file
			bearings = new double[content.size()];
			times = new long[content.size()];

			for (Object object : content) {
				row = (String[]) object;
				/* parsing data from the list to the variables */
				String thisDate = row[0].toString();
				times[counter] = formatter.parseDateTime(thisDate).getMillis();
				bearings[counter] = (Double.parseDouble(row[4].toString()));
				counter++;
			}
		} finally {
			if(csvReader != null)
				csvReader.close();
		}
	}

	public long[] getTimes()
	{
		return times;
	}
	
	public double[] getBearings()
	{
		return bearings;
	}
	
	public List<Double> extractBearings(Long start, Long end) {
		List<Double> thisBearings = new ArrayList<Double>();
		// ok, loop through our data
		for (int i = 0; i < times.length; i++) {
			long thisT = times[i];
			if((thisT >= start) && (thisT <= end))
			{
				thisBearings.add(bearings[i]);
			}
			
		}
		return thisBearings;
	}

	public List<Long> extractTimes(Long start, Long end) {
		List<Long> thisTimes = new ArrayList<Long>();
		// ok, loop through our data
		for (int i = 0; i < times.length; i++) {
			long thisT = times[i];
			if((thisT >= start) && (thisT <= end))
			{
				thisTimes.add(times[i]);
			}
			
		}
		return thisTimes;
	}


}

@@ -98,16 +98,41 @@
 il.List;
+%0Aimport java.util.Random;
 %0A%0Aimport
@@ -333,16 +333,91 @@
 earings;
+%0A%09private double%5B%5D rawBearings;%0A%09private final Random genny = new Random();
 %0A%0A%09publi
@@ -1194,16 +1194,61 @@
 ize()%5D;%0A
+%09%09%09rawBearings = new double%5Bcontent.size()%5D;%0A
 %09%09%09times
@@ -1569,16 +1569,84 @@
 ng()));%0A
+%09%09%09%09rawBearings%5Bcounter%5D = (Double.parseDouble(row%5B4%5D.toString()));%0A
 %09%09%09%09coun
@@ -1723,24 +1723,433 @@
 ();%0A%09%09%7D%0A%09%7D%0A%0A
+%09/** generate a new set of bearings by applying the%0A%09 * provided SD to the raw bearings%0A%09 * @param sd%0A%09 */%0A%09public void applyError(double sd)%0A%09%7B%0A%09%09// loop through the bearings%0A%09%09for (int i = 0; i %3C rawBearings.length; i++)%0A%09%09%7B%0A%09%09%09double thisB = rawBearings%5Bi%5D;%0A%09%09%09// calc a new error%0A%09%09%09double thisBearing = thisB + genny.nextGaussian() * sd;%0A%09%09%09%0A%09%09%09// and store it%0A%09%09%09bearings%5Bi%5D = thisBearing;%0A%09%09%09%0A%09%09%7D%0A%09%7D%0A%09%0A
 %09public long

introduce code to apply SD to raw data