Go to the documentation of this file.
37 cout <<
"Close the window to end.\n";
43 const size_t nClusters =
46 for (
size_t cl = 0; cl < nClusters; cl++)
54 for (
size_t p = 0;
p < nPts;
p++)
65 vector<int> assignments;
71 cout <<
"Took: " << tictac.
Tac() * 1e3 <<
" ms.\n";
72 cout <<
"cost: " << cost << endl;
77 static const char colors[6] = {
'b',
'r',
'k',
'g',
'm',
'c'};
79 for (
size_t c = 0;
c < nClusters;
c++)
83 for (
size_t i = 0; i <
points.size(); i++)
85 if (
size_t(assignments[i]) ==
c)
87 xs.push_back(
points[i][0]);
88 ys.push_back(
points[i][1]);
96 cout <<
"Press any key to generate another random dataset...\n";
101 int main(
int argc,
char** argv)
108 catch (std::exception& e)
110 std::cout <<
"MRPT exception caught: " << e.what() << std::endl;
115 printf(
"Another exception!!");
double kmeanspp(const size_t k, const LIST_OF_VECTORS1 &points, std::vector< int > &assignments, LIST_OF_VECTORS2 *out_centers=nullptr, const size_t attempts=3)
k-means++ algorithm to cluster a list of N points of arbitrary dimensionality into exactly K clusters...
A high-performance stopwatch, with typical resolution of nanoseconds.
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
GLsizei const GLfloat * points
void randomize(const uint32_t seed)
Initialize the PRNG from the given random seed.
double Tac() noexcept
Stops the stopwatch.
std::vector< T, mrpt::aligned_allocator_cpp11< T > > aligned_std_vector
double drawUniform(const double Min, const double Max)
Generate a uniformly distributed pseudo-random number using the MT19937 algorithm,...
mrpt::gui::CDisplayWindow3D::Ptr win
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
CArrayNumeric is an array for numeric types supporting several mathematical operations (actually,...
void Tic() noexcept
Starts the stopwatch.
Classes for creating GUI windows for 2D and 3D visualization.
Create a GUI window and display plots with MATLAB-like interfaces and commands.
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
This base provides a set of functions for maths stuff.
A namespace of pseudo-random numbers generators of diferent distributions.
double drawGaussian1D(const double mean, const double std)
Generate a normally distributed pseudo-random number.
uint32_t drawUniform32bit()
Generate a uniformly distributed pseudo-random number using the MT19937 algorithm,...
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |