error()

  1. error(sketch UddSketch) RETURNS DOUBLE PRECISION

This returns the maximum relative error that a percentile estimate will have (relative to the correct value). This means the actual value will fall in the range defined by approx_percentile(sketch) +/- approx_percentile(sketch)*error(sketch).

This function can only be used on estimators produced by percentile_agg() or uddsketch() calls.

Required arguments

NameTypeDescription
sketchUddSketchThe sketch to determine the error of, usually from a percentile_agg() call

Returns

ColumnTypeDescription
errorDOUBLE PRECISIONThe maximum relative error of any percentile estimate

Sample usage

  1. SELECT error(percentile_agg(data))
  2. FROM generate_series(0, 100) data;
  1. error
  2. -------
  3. 0.001