genbattle / dkm

A generic C++11 k-means clustering implementation
MIT License
209 stars 47 forks source link

invalid probability vector for discrete_distribution #20

Open gabrieldevillers opened 3 years ago

gabrieldevillers commented 3 years ago

Hello,

Thanks for this useful project. I think I have found a suspiscious behavior, you may be interested:

image

I have this assert raised in Microsoft Visual Studio 2017 when running the following code in debug:

void ReproduceAssert()
{
    std::vector<std::array<double, 1>> data;
    data.push_back(std::array<double,1>({1181.43797999999310377461}));
    data.push_back(std::array<double,1>({35.40983650000003990499}));
    data.push_back(std::array<double,1>({15.00000000000000000000}));
    data.push_back(std::array<double,1>({15.00000000000000000000}));
    data.push_back(std::array<double,1>({264.58983650000004672620}));
    data.push_back(std::array<double,1>({18.56102000000697671567}));
    data.push_back(std::array<double,1>({96.22983649999991939694}));
    data.push_back(std::array<double,1>({15.00000000000000000000}));
    data.push_back(std::array<double,1>({10.34999999999968167685}));
    data.push_back(std::array<double,1>({185.00000000000000000000}));
    data.push_back(std::array<double,1>({10.34999999999968167685}));
    data.push_back(std::array<double,1>({89.65000000000031832315}));
    data.push_back(std::array<double,1>({89.65000000000031832315}));
    data.push_back(std::array<double,1>({185.00000000000000000000}));
    data.push_back(std::array<double,1>({10.34999999999968167685}));
    data.push_back(std::array<double,1>({185.00000000000000000000}));
    data.push_back(std::array<double,1>({89.65000000000031832315}));
    dkm::clustering_parameters<double> params(10);
    params.set_random_seed(0);
    params.set_max_iteration(1000);
    auto result = dkm::kmeans_lloyd<double, 1>(data, params);
}