/****************  exo 3 ***************/
/*
 * Created on 18 févr. 2008
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */

public class exo3{
    
  /** display on the screen the table of values of abscissa and ordonnate
    * @param abscs the table of abscica 
    * @param ords the table of ordinate 
    * @return void. 
    **/ 
     public static void displayData(double[] abscs, double[] ords){

       //TODO
	}
       
   /** compute the average . 
    * 
    * @param abscs the table of abcissa 
    * @return a double that is the value of the average. 
    **/ 
   public static double computeAverage(double[] abscs){ 
       double average=0.0;
        // TODO

       return average;
      
   } 
   
   /** calculate the regression coefficient (slope a). 
    * 
    * @param abscs the table of  abscissa 
    * @param ords the table of ordinate 
    * @return the value of the linear regression coefficient. 
    **/ 
   public static double computeCoeffRegression(double[] abscs, double[] ords){ 
        double coeff=0.0;
        //TODO
        return coeff;
   } 

/** calculate the   correlation coefficient). 
    * 
    * @param abscs the table of  abscissa 
    * @param ords the table of ordinate 
   * @return la value du coefficient de correlation. 
    **/ 
   public static double computeCoeffCorrelation(double[] abscs, double[] ords){ 
        double coeff=0.0;
        //TODO
        return coeff;
   } 

 /** calculate corrected points, linear line 
    * @param abscs the table of the  abscissa 
    * @param coeffRegression the regression coefficient
    * @param coeffDecalage the value of offset on the axis y
    * @return the value of  correlation coefficient. 
    **/ 

   public static double[] valuesCorrigees(double[] abscs, double coeffRegression, double valueDecalage){
      double[] tableau = new double[abscs.length];
      //TODO
      return tableau;
   }

  
  /** calculate corrected points, linear line 
    * @param double the average on the  x 
    * @param double the average on the  y
    * @param double coeffRegression  
    * @return double, offset value. 
    **/ 
      public static double computeDecalage(double MoyenneX, double MoyenneY, double coeffRegression){
       double b=0.0;
       //TODO
       return b;
    }

   /** calculate corrected points, linear line 
    * @param double year
    * @param double coeffRegression  
    * @param double value of offset  b  
    * @return double, value of the year 2008. 
    **/ 

   public static double Estimation(double annee2008, double coeffRegression, double valueDecalage){
    double value2008=0.0;
    // TODO
    return value2008;
   }
    
   /** display the curve following several modes 
    * @param abscs the table of  abscissa 
    * @param ords the table of ordinate 
    * @return void 
    **/ 
   public static void printCurve(double[] abscs, double[] ords){ 
         
       //TODO
   } 
   
   public static void main(String[] args){ 

      // initialize the curve (DATA) 

      double[] year = {1990,1992,1994,1996,1998,2000,2002,2004,2006};
      double[] value = {1517.93, 1757.78, 1981.1, 2215.73, 2942.66, 3558.32,4063.91,4521.16,5101.76};
      
      //display the tables of the values
	displayData(year, value);

      //draw the curve
      printCurve(year, value);

      // calculate the different averages
      double MoyenneX = computeMoyenne(year);
      double MoyenneY = computeMoyenne(value);

      // calculate the different coefficients
      double coeffRegression = computeCoeffRegression(year, value);
      double coeffCorrelation = computeCoeffCorrelation(year, value);

      // calculate the value of the offset b
      double valueDecalage = computeDecalage(MoyenneX, MoyenneY, coeffRegression);
      
      // we correct all point values to obtain a linear line
      double[] tabvaluesCorrigees=valuesCorrigees(year, coeffRegression, valueDecalage);

      //draw this linear line
      displayData(year, tabvaluesCorrigees);

      double value2008 = Estimation(2008, coeffRegression, valueDecalage);
   }
}