public class PolyTest {

    public static void main(String[] args) {
	double[] y = new double[32];
	double[] sigma = new double[32];
	double[] x = new double[32];
	
	for(int i=0; i<32; i++) {
	    x[i] = i - 15.5;
	    y[i] = 0.5 * x[i]*x[i] + 0.8 * x[i] - 1.2 + 0.1 * i%2;
	    sigma[i] = 0.1;
	}

	PolynomialModel polynomial = new PolynomialModel(2);
	polynomial.fit(x, y, sigma);
	double[] terms = polynomial.getTerms(2.0);

	for(int p=0; p<polynomial.parameter.length; p++) {
	    System.out.println(polynomial.parameter[p] + " +- " + Math.sqrt(polynomial.covar[p][p]));
	    //System.out.println(terms[p]);
	}
	
	System.out.println();

	System.out.println(polynomial.valueAt(0.0) + " +- " + polynomial.varianceAt(0.0)); 

    }
}
