<div dir="ltr"><div><div>I honestly looked into the code. But gave up when the annotation read: <span class="gmail-pl-c"><span class="gmail-pl-c">/*</span> This is where the magic happens. <span class="gmail-pl-c">*/</span></span><span class="gmail-pl-c">  :D<br></span><pre style="width:1px;height:1px"><a href="https://github.com/postgis/postgis/blob/a0c8db2fbe6279c656962fcfa97aee665266c0a8/liblwgeom/kmeans.h#L124">https://github.com/postgis/postgis/blob/a0c8db2fbe6279c656962fcfa97aee665266c0a8/liblwgeom/kmeans.h#L124</a></pre><br></div><span class="gmail-pl-c">A hint on where to start? Least I can do is compare it to other existing k-means code.<br><br></span></div><span class="gmail-pl-c">Tom<br></span><div><div><span class="gmail-pl-c"><br></span></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 28, 2017 at 8:15 PM, Paul Ramsey <span dir="ltr"><<a href="mailto:pramsey@cleverelephant.ca" target="_blank">pramsey@cleverelephant.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I’ll review a patch, but I won’t do anything about a ticket 😉<br>
The seeding problem is very fiddly as I recall, not a straightforward problem, by any means. Not all inputs are uniform, for example, one size very much does not fit all.<br>
<br>
P<br>
<br>
> On Dec 28, 2017, at 7:24 AM, Tom van Tilburg <<a href="mailto:tom.van.tilburg@gmail.com">tom.van.tilburg@gmail.com</a>> wrote:<br>
><br>
> When running ST_ClusterKmeans on a large amount (>100) of clusters it becomes clear that there is a uneven distribution in the clustering, even when the points are evenly distributed.<br>
><br>
> Consider the following query:<br>
> WITH<br>
> points AS (<br>
>     SELECT (ST_DumpPoints(ST_<wbr>generatePoints(ST_<wbr>MakeEnvelope(0,0,1000,1000),<wbr>100000))).geom geom<br>
> )<br>
> SELECT ST_ClusterKMeans(geom,1000) over () AS cid, geom<br>
> FROM points;<br>
><br>
> This will generate the following clusters:<br>
> <image.png><br>
><br>
> Obviously, clusters on the lowleft, uppright diagonal are smaller then clusters further from this diagonal. Could this be an issue with the starting (random?) seeding?<br>
> If people agree this is undesired behaviour (for me it is), I can file a report.<br>
><br>
> Best,<br>
>  Tom<br>
> ______________________________<wbr>_________________<br>
> postgis-devel mailing list<br>
> <a href="mailto:postgis-devel@lists.osgeo.org">postgis-devel@lists.osgeo.org</a><br>
> <a href="https://lists.osgeo.org/mailman/listinfo/postgis-devel" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/postgis-devel</a><br>
______________________________<wbr>_________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@lists.osgeo.org">postgis-devel@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-devel" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/postgis-devel</a></blockquote></div><br></div>