Created
January 25, 2013 02:20
-
-
Save thisMagpie/4631168 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.*; | |
| import java.util.*; | |
| public class Hall{ | |
| // private static final int rows=8; | |
| // private static final int cols=2; | |
| public static void main (String[] args) throws IOException { | |
| if(args.length>0){ | |
| BufferedReader xReader=new BufferedReader(new FileReader(IOUtil.fileName(args[0]))); | |
| BufferedReader yReader=new BufferedReader(new FileReader(IOUtil.fileName(args[1]))); | |
| Scanner xScan = new Scanner(xReader); | |
| Scanner yScan = new Scanner(yReader); | |
| float xData[][] = new float[16][1]; | |
| float yData[][] = new float[16][1]; | |
| data(xData,xScan); | |
| data(yData,yScan); | |
| PrintWriter outFile = new PrintWriter(new FileWriter("Residuals.dat")); | |
| //PrintWriter outComp = new PrintWriter(new FileWriter("FullGraph.dat")); | |
| System.out.print(" Input the gradient "); | |
| BufferedReader keyboard =new BufferedReader(new InputStreamReader(System.in)); | |
| float gradient = (float) IOUtil.skipToDouble(new Scanner(keyboard)); | |
| float[][] yCalc = StatsUtil.yCalc(xData, gradient); | |
| float[][] residuals = StatsUtil.residuals(yData, yCalc); | |
| residualFile(xData, residuals, outFile); | |
| outFile.close(); | |
| } | |
| } | |
| private static float[][] data(float[][] data, Scanner scan){ | |
| for (int i=1;i<data.length;i++){ | |
| for (int j=0;j<data[i].length;j++){ | |
| data[i][j] = (float) IOUtil.skipToDouble(scan); | |
| } | |
| } | |
| System.out.println(); | |
| return data; | |
| } | |
| public static void residualFile(float[][] x, float[][] y, PrintWriter outFile) { | |
| for (int i=1;i<x.length;i++){ | |
| for (int j=0;j<x[i].length;j++){ | |
| outFile.printf("%2.2f %2.2f \n", x[i][j], y[i][j]); | |
| } | |
| } | |
| System.out.println(); | |
| } | |
| public static void completeDataFile(float[][] x, float[][] y, float[][] errorY, float[][] errorX, PrintWriter outFile) { | |
| for (int i=1;i<x.length;i++){ | |
| for (int j=0;j<x[i].length;j++){ | |
| outFile.printf("%2.2f %2.2f \n", x[i][j], y[i][j]); | |
| } | |
| } | |
| System.out.println(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment