{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/fast-exact-k-means-k-medians-and-bregman","title":"Fast Exact k-Means, k-Medians and Bregman Divergence Clustering in 1D","arxiv_id":"1701.07204","date":"2017-01-25","proceeding":null,"authors":["Allan Grønlund","Kasper Green Larsen","Alexander Mathiasen","Jesper Sindahl Nielsen","Stefan Schneider","Mingzhou Song"],"abstract":"The $k$-Means clustering problem on $n$ points is NP-Hard for any dimension\n$d\\ge 2$, however, for the 1D case there exists exact polynomial time\nalgorithms. Previous literature reported an $O(kn^2)$ time dynamic programming\nalgorithm that uses $O(kn)$ space. It turns out that the problem has been\nconsidered under a different name more than twenty years ago. We present all\nthe existing work that had been overlooked and compare the various solutions\ntheoretically. Moreover, we show how to reduce the space usage for some of\nthem, as well as generalize them to data structures that can quickly report an\noptimal $k$-Means clustering for any $k$. Finally we also generalize all the\nalgorithms to work for the absolute distance and to work for any Bregman\nDivergence. We complement our theoretical contributions by experiments that\ncompare the practical performance of the various algorithms.","url_abs":"http://arxiv.org/abs/1701.07204v4","url_pdf":"http://arxiv.org/pdf/1701.07204v4.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"fast-exact-k-means-k-medians-and-bregman","repo_url":"https://github.com/apple/ml-stable-diffusion","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"fast-exact-k-means-k-medians-and-bregman","repo_url":"https://github.com/dstein64/kmeans1d","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"clustering","task_name":"Clustering"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/1701.07204","atlas_url":"https://app.syntology.ai/?focus=1701.07204","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"1701.07204"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/apple/ml-stable-diffusion","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/dstein64/kmeans1d","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":1,"unverified":14},"by_repo_kind":{"listed":{"samples":15,"ran":1,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"b41e987fee8a92ff","entry":"correct_for_bias_scale_order_inversion","repo":"apple/ml-stable-diffusion","repo_kind":"listed","path":"python_coreml_stable_diffusion/unet.py","file_url":"https://github.com/apple/ml-stable-diffusion/blob/HEAD/python_coreml_stable_diffusion/unet.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b41e987fee8a92ff"}},{"code_sha256_prefix":"89b4b82b53ec08d3","entry":"bundle_resources_for_swift_cli","repo":"apple/ml-stable-diffusion","repo_kind":"listed","path":"python_coreml_stable_diffusion/torch2coreml.py","file_url":"https://github.com/apple/ml-stable-diffusion/blob/HEAD/python_coreml_stable_diffusion/torch2coreml.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"89b4b82b53ec08d3"}},{"code_sha256_prefix":"03a2c78ee113d2d7","entry":"compute_psnr","repo":"apple/ml-stable-diffusion","repo_kind":"listed","path":"python_coreml_stable_diffusion/torch2coreml.py","file_url":"https://github.com/apple/ml-stable-diffusion/blob/HEAD/python_coreml_stable_diffusion/torch2coreml.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"03a2c78ee113d2d7"}},{"code_sha256_prefix":"f30782804dc508d6","entry":"fake_palettize","repo":"apple/ml-stable-diffusion","repo_kind":"listed","path":"python_coreml_stable_diffusion/mixed_bit_compression_pre_analysis.py","file_url":"https://github.com/apple/ml-stable-diffusion/blob/HEAD/python_coreml_stable_diffusion/mixed_bit_compression_pre_analysis.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f30782804dc508d6"}},{"code_sha256_prefix":"2f1e5140bafa7aef","entry":"get_activation","repo":"apple/ml-stable-diffusion","repo_kind":"listed","path":"python_coreml_stable_diffusion/unet.py","file_url":"https://github.com/apple/ml-stable-diffusion/blob/HEAD/python_coreml_stable_diffusion/unet.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2f1e5140bafa7aef"}},{"code_sha256_prefix":"642fa931a88fc1e7","entry":"get_image_path","repo":"apple/ml-stable-diffusion","repo_kind":"listed","path":"python_coreml_stable_diffusion/pipeline.py","file_url":"https://github.com/apple/ml-stable-diffusion/blob/HEAD/python_coreml_stable_diffusion/pipeline.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"642fa931a88fc1e7"}},{"code_sha256_prefix":"113401d8e5e84a63","entry":"get_palettizable_modules","repo":"apple/ml-stable-diffusion","repo_kind":"listed","path":"python_coreml_stable_diffusion/mixed_bit_compression_pre_analysis.py","file_url":"https://github.com/apple/ml-stable-diffusion/blob/HEAD/python_coreml_stable_diffusion/mixed_bit_compression_pre_analysis.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"113401d8e5e84a63"}},{"code_sha256_prefix":"4d818e58dff62db6","entry":"get_resource_type","repo":"apple/ml-stable-diffusion","repo_kind":"listed","path":"python_coreml_stable_diffusion/coreml_model.py","file_url":"https://github.com/apple/ml-stable-diffusion/blob/HEAD/python_coreml_stable_diffusion/coreml_model.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4d818e58dff62db6"}},{"code_sha256_prefix":"1b333fb5bbf14039","entry":"get_timestep_embedding","repo":"apple/ml-stable-diffusion","repo_kind":"listed","path":"python_coreml_stable_diffusion/unet.py","file_url":"https://github.com/apple/ml-stable-diffusion/blob/HEAD/python_coreml_stable_diffusion/unet.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"1b333fb5bbf14039"}},{"code_sha256_prefix":"18168e89cf505855","entry":"prepare_controlnet_cond","repo":"apple/ml-stable-diffusion","repo_kind":"listed","path":"python_coreml_stable_diffusion/pipeline.py","file_url":"https://github.com/apple/ml-stable-diffusion/blob/HEAD/python_coreml_stable_diffusion/pipeline.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"18168e89cf505855"}},{"code_sha256_prefix":"9176106657a6f8cb","entry":"report_correctness","repo":"apple/ml-stable-diffusion","repo_kind":"listed","path":"python_coreml_stable_diffusion/torch2coreml.py","file_url":"https://github.com/apple/ml-stable-diffusion/blob/HEAD/python_coreml_stable_diffusion/torch2coreml.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9176106657a6f8cb"}},{"code_sha256_prefix":"e47c68e7594be7c2","entry":"softmax","repo":"apple/ml-stable-diffusion","repo_kind":"listed","path":"python_coreml_stable_diffusion/attention.py","file_url":"https://github.com/apple/ml-stable-diffusion/blob/HEAD/python_coreml_stable_diffusion/attention.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e47c68e7594be7c2"}},{"code_sha256_prefix":"6b677435d1b8264e","entry":"split_einsum","repo":"apple/ml-stable-diffusion","repo_kind":"listed","path":"python_coreml_stable_diffusion/attention.py","file_url":"https://github.com/apple/ml-stable-diffusion/blob/HEAD/python_coreml_stable_diffusion/attention.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6b677435d1b8264e"}},{"code_sha256_prefix":"37852742dbb608cb","entry":"split_einsum_v2","repo":"apple/ml-stable-diffusion","repo_kind":"listed","path":"python_coreml_stable_diffusion/attention.py","file_url":"https://github.com/apple/ml-stable-diffusion/blob/HEAD/python_coreml_stable_diffusion/attention.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"37852742dbb608cb"}},{"code_sha256_prefix":"e32b33bc6adf989c","entry":"unet_data_loader","repo":"apple/ml-stable-diffusion","repo_kind":"listed","path":"python_coreml_stable_diffusion/activation_quantization.py","file_url":"https://github.com/apple/ml-stable-diffusion/blob/HEAD/python_coreml_stable_diffusion/activation_quantization.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e32b33bc6adf989c"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}