Lines Matching refs:weights
436 def fmean(data, weights=None):
455 if weights is None:
461 num_weights = len(weights)
463 weights = list(weights)
464 num_weights = len(weights)
465 num = fsum(map(mul, data, weights))
467 raise StatisticsError('data and weights must be the same length')
468 den = fsum(weights)
470 raise StatisticsError('sum of weights must be non-zero')
493 def harmonic_mean(data, weights=None):
510 >>> harmonic_mean([40, 60], weights=[5, 30])
522 elif n == 1 and weights is None:
530 if weights is None:
531 weights = repeat(1, n)
534 if iter(weights) is weights:
535 weights = list(weights)
536 if len(weights) != n:
537 raise StatisticsError('Number of weights does not match data size')
538 _, sum_weights, _ = _sum(w for w in _fail_neg(weights, errmsg))
541 T, total, count = _sum(w / x if w else 0 for w, x in zip(weights, data))