tatobari / hx711py

HX711 Python Library for Raspberry Pi.
Apache License 2.0
206 stars 154 forks source link

wrong calculation of the arithmetic mean? #52

Open OrnellaT opened 1 year ago

OrnellaT commented 1 year ago

Hello,

In case of an even number, to get the arithmetic mean of the two middle values, shouldn't it be:

midpoint = len(valueList) // 2
return sum(valueList[midpoint-1:midpoint+1]) / 2.0

instead of:

midpoint = len(valueList) / 2
return sum(valueList[midpoint:midpoint+2]) / 2.0

https://github.com/tatobari/hx711py/blob/14a8e3f66006e14fe13d3f2961af46b1afbc2317/hx711.py#L224 ?