avgWeighted

Calculates the weighted arithmetic mean.

Syntax

  1. avgWeighted(x, weight)

Parameters

Type of x and weight must be the same.

Returned value

  • Weighted mean.
  • NaN. If all the weights are equal to 0.

Type: Float64.

Example

Query:

  1. SELECT avgWeighted(x, w)
  2. FROM values('x Int8, w Int8', (4, 1), (1, 0), (10, 2))

Result:

  1. ┌─avgWeighted(x, weight)─┐
  2. 8
  3. └────────────────────────┘