Avg fix

Quick fix for ratio(...) mistake. Are there better fixes @zmyao88 @schafik ?