2.1.0
User Documentation for Apache MADlib
sample.sql_in File Reference

SQL functions for random sampling. More...

Functions

bytea8 weighted_sample_transition_int64 (bytea8 state, bigint value, float8 weight)
 
bytea8 weighted_sample_merge_int64 (bytea8 state_left, bytea8 state_right)
 
bigint weighted_sample_final_int64 (bytea8 state)
 
aggregate bytea8 weighted_sample (bigint value, float8 weight)
 Sample a single row according to weights. More...
 
bytea8 weighted_sample_transition_vector (bytea8 state, float8[] value, float8 weight)
 
bytea8 weighted_sample_merge_vector (bytea8 state_left, bytea8 state_right)
 
float8 [] weighted_sample_final_vector (bytea8 state)
 
aggregate bytea8 weighted_sample (float8[] value, float8 weight)
 
integer poisson_random (float8 mean)
 
float8 gamma_random (float8 alpha)
 
integer index_weighted_sample (float8[])
 

Detailed Description

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

Function Documentation

◆ gamma_random()

float8 gamma_random ( float8  alpha)

◆ index_weighted_sample()

integer index_weighted_sample ( float8  [])

◆ poisson_random()

integer poisson_random ( float8  mean)

◆ weighted_sample() [1/2]

aggregate bytea8 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).

◆ weighted_sample() [2/2]

aggregate bytea8 weighted_sample ( float8 []  value,
float8  weight 
)

◆ weighted_sample_final_int64()

bigint weighted_sample_final_int64 ( bytea8  state)

◆ weighted_sample_final_vector()

float8 [] weighted_sample_final_vector ( bytea8  state)

◆ weighted_sample_merge_int64()

bytea8 weighted_sample_merge_int64 ( bytea8  state_left,
bytea8  state_right 
)

◆ weighted_sample_merge_vector()

bytea8 weighted_sample_merge_vector ( bytea8  state_left,
bytea8  state_right 
)

◆ weighted_sample_transition_int64()

bytea8 weighted_sample_transition_int64 ( bytea8  state,
bigint  value,
float8  weight 
)

◆ weighted_sample_transition_vector()

bytea8 weighted_sample_transition_vector ( bytea8  state,
float8 []  value,
float8  weight 
)