Statistics::variance() and Statistics::avg() functions can be gas optimized. Caching data.length and only accessing it once will reduce repetitive data.length calls and the diff definition can be completely removed.
variance and avg calculations can be optimized. In both Statistics::variance() and Statistics::avg() functions accessing data.length in each iteration is costly. Caching it in a variable uint256 len = data.length; will save gas. In Statistics::variance() function the diff definition can be removed. Removing diff altogether or computing inline can be a little more gas-efficient since it avoids the extra stack operation to save diff on each iteration.
Without the suggested optimizations the executions of these function will cost more gas.
Manual audit
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.