Module provides various random sampling algorithms. More...
Functions | |
def | reservoir_r (data, n) |
Performs data sampling using Reservoir Algorithm R. More... | |
def | reservoir_x (data, n) |
Performs data sampling using Reservoir Algorithm X. More... | |
Module provides various random sampling algorithms.
def pyclustering.utils.sampling.reservoir_r | ( | data, | |
n | |||
) |
Performs data sampling using Reservoir Algorithm R.
Algorithm complexity O(n). Implementation is based on paper [40]. Average number of uniform random variates: .
[in] | data | (list): Input data for sampling. |
[in] | n | (uint): Size of sample that should be extracted from 'data'. |
Generate random samples with 5 elements and with 3 elements using Reservoir Algorithm R:
Output example for the code above:
Definition at line 30 of file sampling.py.
def pyclustering.utils.sampling.reservoir_x | ( | data, | |
n | |||
) |
Performs data sampling using Reservoir Algorithm X.
Algorithm complexity O(n). Implementation is based on paper [40]. Average number of uniform random variates:
[in] | data | (list): Input data for sampling. |
[in] | n | (uint): Size of sample that should be extracted from 'data'. |
Generate random sample with 5 elements using Reservoir Algorithm X:
Output example for the code above:
Definition at line 72 of file sampling.py.