def skew(arr, mode="float"): """ This function calculates the skew of a given array Note that the mode must be specified as the automatic mode is float in this case """ if len(arr) == 0: raise ValueError('Empty dataset') average = bf.average(arr, mode) answer = (bf.add([(average - i)**2 for i in arr], mode) / len(arr))**(1 / 2) return answer
def _(): assert bf.average([1, 2, 3, 4, 5, 6]) == 3.5
def _(): assert bf.average([1, 3]) == 2.0
def _(): assert bf.average([1.0]) == 1.0
def _(): assert bf.average([]) == 0.0