MADlib
1.1 A newer version is available
User Documentation
|
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... | |
Definition in file sample.sql_in.
aggregate bigint weighted_sample | ( | bigint | value, |
float8 | weight | ||
) |
value | Value 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. |
weight | Weight for row. A negative value here is treated has zero weight. |
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.