Changeset 3992


Ignore:
Timestamp:
04/29/08 12:54:06 (12 years ago)
Author:
curtis
Message:

Fix jikes warnings, and ignore .class files.

Location:
trunk/loci/slim
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/slim

    • Property svn:ignore set to
      *.class
  • trunk/loci/slim/CurveFitter.java

    r3989 r3992  
    11package loci.slim; 
    22 
    3 public interface CurveFitter { 
     3interface CurveFitter { 
    44 
    55  /** 
     
    88   * information returned by getCurve and getChiSquaredError 
    99   **/ 
    10   public void iterate(); 
     10  void iterate(); 
    1111 
    1212  // Returns the Chi Squared Error of the current curve estimate 
    13   public double getChiSquaredError(); 
     13  double getChiSquaredError(); 
    1414 
    1515  // Returns the Reduced Chi Squared Error of the current curve estimate 
    1616  // This is based on the number of datapoints in data and the number 
    1717  // of exponentials in setDegrees 
    18   public double getReducedChiSquaredError(); 
     18  double getReducedChiSquaredError(); 
    1919   
    2020  /** 
     
    2424   * TODO: Do I actually need the time values, or can I hardcode? 
    2525   **/ 
    26   public void setData(double[][] data); 
     26  void setData(double[][] data); 
    2727 
    2828  // TODO: Set time domain? 
     
    3333   * TODO: Change Degrees to exponentials or whatever 
    3434   **/ 
    35   public void setDegrees(int degrees); 
     35  void setDegrees(int degrees); 
    3636 
    3737  // Returns the number of exponentials to be fitted. 
    38   public int getDegrees(); 
     38  int getDegrees(); 
    3939 
    4040  // Initializes the curve fitter with a starting curve estimate. 
    41   public void estimate(); 
     41  void estimate(); 
    4242 
    4343  /** 
     
    4848   * TODO: Make multiple exponentials a class, to remove multi-c stupidity 
    4949   **/ 
    50   public double[][] getCurve(); 
     50  double[][] getCurve(); 
    5151 
    5252  /** 
     
    5555   * See getCurve for information about the array to pass. 
    5656   **/ 
    57   public void setCurve(double[][] curve); 
     57  void setCurve(double[][] curve); 
    5858 
    5959} 
  • trunk/loci/slim/GACurveFitter.java

    r3989 r3992  
    242242      // TODO: Estimate c, factor it in below. 
    243243      /* 
    244       double guess_c = Double.MAX_VALUE; 
     244      double guessC = Double.MAX_VALUE; 
    245245      for(int i = 0; i < curveData.length; i++) { 
    246         if(curveData[i][1] < guess_c) guess_c = curveData[i][1]; 
     246        if(curveData[i][1] < guessC) guessC = curveData[i][1]; 
    247247      } 
    248248      */ 
    249249 
    250       double guess_c = 0.0d; 
     250      double guessC = 0.0d; 
    251251       
    252252      // First, get a guess for the exponent. 
     
    256256      double den = 0.0; 
    257257      for(int i = 1; i < curveData.length; i++) { 
    258         if(curveData[i][1] > guess_c && curveData[i-1][1] > guess_c) { 
     258        if(curveData[i][1] > guessC && curveData[i-1][1] > guessC) { 
    259259          double time = curveData[i][0] - curveData[i-1][0]; 
    260           double factor = (curveData[i][1] - guess_c) / (curveData[i-1][1] - guess_c); 
     260          double factor = (curveData[i][1] - guessC) / (curveData[i-1][1] - guessC); 
    261261          double guess = (1.0 / time) * -Math.log(factor); 
    262           num += (guess * (curveData[i][1] - guess_c)); 
    263           den += curveData[i][1] - guess_c; 
     262          num += (guess * (curveData[i][1] - guessC)); 
     263          den += curveData[i][1] - guessC; 
    264264        } 
    265265      } 
     
    268268      den = 0.0; 
    269269      for(int i = 0; i < curveData.length; i++) { 
    270         if(curveData[i][1] > guess_c) { 
     270        if(curveData[i][1] > guessC) { 
    271271          // calculate e^-bt based on our exponent estimate 
    272272          double value = Math.pow(Math.E, -curveData[i][0] * exp); 
    273273          // estimate a 
    274           double guess_a = curveData[i][1] / value; 
    275           num += guess_a * (curveData[i][1] - guess_c); 
    276           den += curveData[i][1] - guess_c; 
     274          double guessA = curveData[i][1] / value; 
     275          num += guessA * (curveData[i][1] - guessC); 
     276          den += curveData[i][1] - guessC; 
    277277        } 
    278278      } 
     
    280280      curveEstimate[0][0] = mult; 
    281281      curveEstimate[0][1] = exp; 
    282       curveEstimate[0][2] = guess_c; 
     282      curveEstimate[0][2] = guessC; 
    283283    } 
    284284    if(degrees == 2) { 
    285       double guess_c = 0.0d; 
    286       curveEstimate[0][2] = guess_c; 
    287       curveEstimate[1][2] = guess_c; 
     285      double guessC = 0.0d; 
     286      curveEstimate[0][2] = guessC; 
     287      curveEstimate[1][2] = guessC; 
    288288       
    289289      // First, get a guess for the exponents. 
     
    292292      double low = Double.MAX_VALUE; 
    293293      for(int i = 3; i < curveData.length; i++) { 
    294         if(curveData[i][1] > guess_c && curveData[i-3][1] > guess_c + 10) { 
     294        if(curveData[i][1] > guessC && curveData[i-3][1] > guessC + 10) { 
    295295          double time = curveData[i][0] - curveData[i-3][0]; 
    296           double factor = (curveData[i][1] - guess_c) / (curveData[i-3][1] - guess_c); 
     296          double factor = (curveData[i][1] - guessC) / (curveData[i-3][1] - guessC); 
    297297          double guess = (1.0 / time) * -Math.log(factor); 
    298298          if(guess > high) high = guess; 
     
    305305      curveEstimate[1][1] = low; 
    306306 
    307       double high_a = 0.0d; 
    308       double low_a = Double.MAX_VALUE; 
     307      double highA = 0.0d; 
     308      double lowA = Double.MAX_VALUE; 
    309309      for(int i = 0; i < curveData.length; i++) { 
    310         if(curveData[i][1] > guess_c + 10) { 
     310        if(curveData[i][1] > guessC + 10) { 
    311311          // calculate e^-bt based on our exponent estimate 
    312312          double value = Math.pow(Math.E, -curveData[i][0] * low); 
    313313          // estimate a 
    314           double guess_a = curveData[i][1] / value; 
    315           if(guess_a > high_a) high_a = guess_a; 
    316           if(guess_a < low_a) low_a = guess_a; 
    317         } 
    318       } 
    319       if(10.0 > low_a) low_a = 10.0; 
    320       if(20.0 > high_a) high_a = 20.0; 
    321       curveEstimate[0][0] = high_a - low_a; 
    322       curveEstimate[1][0] = low_a; 
     314          double guessA = curveData[i][1] / value; 
     315          if(guessA > highA) highA = guessA; 
     316          if(guessA < lowA) lowA = guessA; 
     317        } 
     318      } 
     319      if(10.0 > lowA) lowA = 10.0; 
     320      if(20.0 > highA) highA = 20.0; 
     321      curveEstimate[0][0] = highA - lowA; 
     322      curveEstimate[1][0] = lowA; 
    323323      // It seems like the low estimates are pretty good, usually. 
    324324      // It may be possible to get a better high estimate by subtracting out 
    325325      // the low estimate, and then recalculating as if it were single 
    326326      // exponential. 
    327       double[][] low_est = new double[1][3]; 
    328       low_est[0][0] = curveEstimate[1][0]; 
    329       low_est[0][1] = curveEstimate[1][1]; 
    330       low_est[0][2] = curveEstimate[1][2]; 
    331       double[] low_data = getEstimates(curveData, low_est); 
    332       double[][] low_values = new double[curveData.length][2]; 
    333       for(int i = 0; i < low_values.length; i++) { 
    334         low_values[i][0] = curveData[i][0]; 
    335         low_values[i][1] = curveData[i][1] - low_data[i]; 
    336       } 
    337  
    338       // now, treat low_values as a single exponent. 
     327      double[][] lowEst = new double[1][3]; 
     328      lowEst[0][0] = curveEstimate[1][0]; 
     329      lowEst[0][1] = curveEstimate[1][1]; 
     330      lowEst[0][2] = curveEstimate[1][2]; 
     331      double[] lowData = getEstimates(curveData, lowEst); 
     332      double[][] lowValues = new double[curveData.length][2]; 
     333      for(int i = 0; i < lowValues.length; i++) { 
     334        lowValues[i][0] = curveData[i][0]; 
     335        lowValues[i][1] = curveData[i][1] - lowData[i]; 
     336      } 
     337 
     338      // now, treat lowValues as a single exponent. 
    339339      double num = 0.0; 
    340340      double den = 0.0; 
    341       for(int i = 1; i < low_values.length; i++) { 
    342         if(low_values[i][1] > guess_c && low_values[i-1][1] > guess_c) { 
    343           double time = low_values[i][0] - low_values[i-1][0]; 
    344           double factor = (low_values[i][1] - guess_c) / (low_values[i-1][1] - guess_c); 
     341      for(int i = 1; i < lowValues.length; i++) { 
     342        if(lowValues[i][1] > guessC && lowValues[i-1][1] > guessC) { 
     343          double time = lowValues[i][0] - lowValues[i-1][0]; 
     344          double factor = (lowValues[i][1] - guessC) / (lowValues[i-1][1] - guessC); 
    345345          double guess = (1.0 / time) * -Math.log(factor); 
    346           num += (guess * (low_values[i][1] - guess_c)); 
    347           den += low_values[i][1] - guess_c; 
     346          num += (guess * (lowValues[i][1] - guessC)); 
     347          den += lowValues[i][1] - guessC; 
    348348        } 
    349349      } 
     
    351351      num = 0.0; 
    352352      den = 0.0; 
    353       for(int i = 0; i < low_values.length; i++) { 
    354         if(low_values[i][1] > guess_c) { 
     353      for(int i = 0; i < lowValues.length; i++) { 
     354        if(lowValues[i][1] > guessC) { 
    355355          // calculate e^-bt based on our exponent estimate 
    356           double value = Math.pow(Math.E, -low_values[i][0] * exp); 
     356          double value = Math.pow(Math.E, -lowValues[i][0] * exp); 
    357357          // estimate a 
    358           double guess_a = low_values[i][1] / value; 
    359           num += guess_a * (low_values[i][1] - guess_c); 
    360           den += low_values[i][1] - guess_c; 
     358          double guessA = lowValues[i][1] / value; 
     359          num += guessA * (lowValues[i][1] - guessC); 
     360          den += lowValues[i][1] - guessC; 
    361361        } 
    362362      } 
     
    364364      curveEstimate[0][0] = mult; 
    365365      curveEstimate[0][1] = exp; 
    366       curveEstimate[0][2] = guess_c; 
     366      curveEstimate[0][2] = guessC; 
    367367      // TODO: It may be possible to tweak the estimate further by adjusting 
    368368      // the values of a to more accurately account for actual values, instead 
Note: See TracChangeset for help on using the changeset viewer.