random_selection.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_METHODS_NYSTROEM_METHOD_RANDOM_SELECTION_HPP
15 #define MLPACK_METHODS_NYSTROEM_METHOD_RANDOM_SELECTION_HPP
16 
17 #include <mlpack/prereqs.hpp>
18 
19 namespace mlpack {
20 namespace kernel {
21 
23 {
24  public:
32  const static arma::Col<size_t> Select(const arma::mat& data, const size_t m)
33  {
34  arma::Col<size_t> selectedPoints(m);
35  for (size_t i = 0; i < m; ++i)
36  selectedPoints(i) = math::RandInt(0, data.n_cols);
37 
38  return selectedPoints;
39  }
40 };
41 
42 } // namespace kernel
43 } // namespace mlpack
44 
45 #endif
static const arma::Col< size_t > Select(const arma::mat &data, const size_t m)
Randomly select the specified number of points in the dataset.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
int RandInt(const int hiExclusive)
Generates a uniform random integer.
Definition: random.hpp:110