Changeset 4219
 Timestamp:
 07/22/08 12:01:02 (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/loci/slim/GACurveFitter.java
r4214 r4219 1 // TODO: Tau cannot be negative. >_< 1 2 // 2 3 // GACurveFitter.java … … 169 170 } 170 171 } 172 for(int q = 0; q < curveEstimate.length; q++) { 173 System.out.println("c" + q + ": " + curveEstimate[q][2]); 174 } 171 175 } 172 176 173 177 // Returns the Chi Squared Error of the current curve estimate 174 178 public double getChiSquaredError() { 179 System.out.println("**********"); 175 180 double total = 0.0d; 176 181 double[] expected = getEstimates(curveData, curveEstimate); … … 183 188 // (oe)^2 / e 184 189 term /= expected[i]; 185 //System.out.println("Obs: " + observed +186 //" Expect: " + expected[i] + " Term: " + term);190 System.out.println("Obs: " + observed + 191 " Expect: " + expected[i] + " Term: " + term); 187 192 total += term; 188 193 } … … 235 240 if (degrees >= 1) { 236 241 // TODO: Estimate c, factor it in below. 237 /*242 238 243 double guessC = Double.MAX_VALUE; 239 244 for (int i = 0; i < curveData.length; i++) { 240 if (curveData[i] [1] < guessC) guessC = curveData[i][1];241 } 242 */243 244 double guessC = 0.0d;245 if (curveData[i] < guessC) guessC = curveData[i]; 246 } 247 248 249 //double guessC = 0.0d; 245 250 246 251 // First, get a guess for the exponent. … … 256 261 (curveData[i]  guessC) / (curveData[i1]  guessC); 257 262 double guess = 1.0 * Math.log(factor); 263 System.out.println("Guess: " + guess + " Factor: " + factor); 258 264 num += (guess * (curveData[i]  guessC)); 259 265 den += curveData[i]  guessC; … … 261 267 } 262 268 double exp = num/den; 269 System.out.println("Final exp guess: " + exp); 263 270 num = 0.0; 264 271 den = 0.0; 265 for (int i = 0; i < curveData.length; i++) { 272 // Hacky... we would like to do this over the entire curve length, 273 // but the actual data is far too noisy to do this. Instead, we'll just 274 // do it for the first 5, which have the most data. 275 //for (int i = 0; i < curveData.length; i++) { 276 for(int i = 0; i < 5; i++) { 266 277 if (curveData[i] > guessC) { 267 278 // calculate e^bt based on our exponent estimate 268 279 double value = Math.pow(Math.E, i * exp); 269 280 // estimate a 270 double guessA = curveData[i]/ value;281 double guessA = (curveData[i]  guessC) / value; 271 282 num += guessA * (curveData[i]  guessC); 272 283 den += curveData[i]  guessC; 284 System.out.println("Data: " + curveData[i] + " Value: " + value + " guessA: " + guessA); 273 285 } 274 286 } … … 279 291 } 280 292 if (degrees == 2) { 281 double guessC = 0.0d; 293 double guessC = Double.MAX_VALUE; 294 for(int i = 0; i < curveData.length; i++) { 295 if(curveData[i] < guessC) guessC = curveData[i]; 296 } 282 297 curveEstimate[0][2] = guessC; 283 curveEstimate[1][2] = guessC;298 curveEstimate[1][2] = 0; 284 299 285 300 // First, get a guess for the exponents. … … 307 322 double highA = 0.0d; 308 323 double lowA = Double.MAX_VALUE; 309 for (int i = 0; i < curveData.length; i++) { 324 //for (int i = 0; i < curveData.length; i++) { 325 for(int i = 0; i < 5; i++) { 310 326 if (curveData[i] > guessC + 10) { 311 327 // calculate e^bt based on our exponent estimate … … 354 370 num = 0.0; 355 371 den = 0.0; 356 for (int i = 0; i < lowValues.length; i++) { 372 //for (int i = 0; i < lowValues.length; i++) { 373 for(int i = 0; i < 5; i++) { 357 374 if (lowValues[i][1] > guessC) { 358 375 // calculate e^bt based on our exponent estimate … … 375 392 // For now, however, this produces reasonably good estimates, good 376 393 // enough to start the GA process. 394 395 // Fix bug where the estimate occasionally produces negative 396 // tau values. If this happens, we'll sort it out in iteration. 397 if(curveEstimate[0][1] <= 0) curveEstimate[0][1] = 2000; 398 if(curveEstimate[1][1] <= 0) curveEstimate[1][1] = 800; 399 377 400 378 401 }
Note: See TracChangeset
for help on using the changeset viewer.