User Documentation
 All Files Functions Groups
sample.sql_in File Reference

SQL functions for random sampling. More...

Go to the source code of this file.

Functions

aggregate bigint weighted_sample (bigint value, float8 weight)
 Sample a single row according to weights. More...
 

Detailed Description

See Also
For an overview of random-sampling functions, see the module description Random Sampling.

Definition in file sample.sql_in.

Function Documentation

aggregate bigint weighted_sample ( bigint  value,
float8  weight 
)
Parameters
valueValue of row. Uniqueness is not enforced. If a value occurs multiple times, the probability of sampling this value is proportional to the sum of its weights.
weightWeight for row. A negative value here is treated has zero weight.
Returns
identifier of the selected row. The probability of sampling any particular row (value, weight) is weight/SUM(weight).

Definition at line 93 of file sample.sql_in.