View Single Post
  #8 (permalink)  
Old 09-08-2004, 11:24 AM
accwai's Avatar
accwai accwai is offline
Enthusiast
 
Real Name: Andy Wai
Location: Toronto, Canada
Hybrids: 2004 Prius
Posts: 47
Default

Quote:
Originally posted by Jason+Sep 8th 2004 @ 11:22 AM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (Jason @ Sep 8th 2004 @ 11:22 AM)</td></tr><tr><td id='QUOTE'>[...] If you can provide a better equation to determine weighted mileage and gallons based on the distance and mileage of each tank, I will do my best to implement that equation.[/b]

Since mileage = distance/gallons, we can flip things around and have gallons = distance/mileage. Since these last two are stored, individual tank gallons can always be derived precisely. What's left then is to get the total distance then divide it by total gallons, with something like this:

Code:
$numerator = 0; $denominator = 0; while ( $weight = mysql_fetch_array($weightresult) ) { $numerator += $weight['distance']; $denominator += $weight['distance']/$weight['mileage']; } $mileage = $numerator/$denominator;
Sounds plausible?

<!--QuoteBegin-Jason
@Sep 8th 2004 @ 11:22 AM
[...]I will do my best to implement that equation. I cannot for the life of me, however, understand how the discrepancy happened in the first place.[/quote]
I have a gut feeling that weighting based on percentage distance is not enough for the below average tanks. Need some time to think it through. Get back to you in a day or so...

Andy
Reply With Quote