MCPcopy Create free account
hub / github.com/Lauriat/funct / average

Method average

funct/Array.py:194–199  ·  view source on GitHub ↗

Returns the weighted average of the Array elements.

(self, weights=None)

Source from the content-addressed store, hash-verified

192 return sum(self) / self.size
193
194 def average(self, weights=None):
195 """ Returns the weighted average of the Array elements. """
196 if weights is None:
197 return sum(self) / self.size
198 else:
199 return sum(self.mul(weights)) / sum(weights)
200
201 def floor(self, inplace=False):
202 """ Floors the Array elements. """

Callers 1

testMethod · 0.80

Calls 1

mulMethod · 0.95

Tested by 1

testMethod · 0.64