【问题标题】:Generate random points in a Voronoi region, and creating Voronoi regions with high dimensional data在 Voronoi 区域中生成随机点,并使用高维数据创建 Voronoi 区域
【发布时间】:2014-01-14 11:27:24
【问题描述】:

我正在使用 k-means 聚类算法,对于每个聚类质心,我正在尝试为质心生成 n 维 Voronoi 区域。之后我需要从 Voronoi 区域生成随机点。

我尝试使用 Matlab/Octave 和 scipy 来获得 n 维 Voronoi 区域。但我有两个问题。

  • 生成顶点和区域后,如何从区域生成随机数据
  • 如果聚类质心的数量小于 n 维数,是否可以构造 Voronoi 区域

编辑 -

我的主要目标是生成一个密码本。我有 60k 个 n 维数据点,我想创建一个包含 512 个码字的码本,其中每个码字都是 n 维的。码本是原始数据的近似值。集群将是这样做的一种方式。由于 k-means 需要很长时间,我想使用 Adaptive Iterative LBG(由 Shen Furao 和 Osamu Hasegawa 编写),其过程是 -

  • 找到误差最大的集群质心 - 我们称之为 C_large
  • 在 C_large 的 Voronoi 区域生成一个随机点,我们称之为 C_new
  • 使用 voronoi 区域中的数据点运行 k-means,只有两个质心 C_large 和 C_new

这将比 k-means 运行得快得多,因为每次 k-means 都使用总数据点的一个子集和两个质心运行。

但是,算法从 k=1 开始。但是直到 k>n(其中数据是 n 维的)我无法使用 scipy 或 Octave 找到 Voronoi 区域。

所以如果我有一个质心,如 C,在 Octave 中运行 voronoin(C) 会给我

error: voronoin: number of points must be greater than their dimension

那么有没有办法在这种情况下生成 Voronoi 区域。

对于我的第二个问题,已经给出了很好的答案。

不过,我想问另一个相关的问题。由于 Octave 中的 voronoin(C) 在 C 中的点数小于 n(维度#)时不起作用,我尝试运行简单的 k-means 50 次,以获得 50 个簇质心。然后当我尝试运行 voronoin(C),其中 C 是一个大小为 50X36 的矩阵,所以有 50 个簇质心,每个是一个 36 维点,我得到以下错误 -

qhull error (qh_memalloc): insufficient memory

While executing:  | qhull v Qbb Qx
Options selected for Qhull 2009.1 2009/06/14:
  voronoi  Qbbound-last  Qxact-merge  _zero-centrum  Pgood
  Q3-no-merge-vertices-dim-high  _max-width 1.6  Error-roundoff 9.4e-14
  _one-merge 7.6e-12  _near-inside 3.8e-11  Visible-distance 5.6e-13
  U-coplanar-distance 5.6e-13  Width-outside 1.1e-12  _wide-facet 3.4e-12
Last point added to hull was p23.

At error exit:

Voronoi diagram by the convex hull of 50 points in 40-d:

  Number of Voronoi regions: 48
  Total number of nearly incident points: 2
  Number of Voronoi vertices: 0

Statistics for:  | qhull v Qbb Qx

  Number of points processed: 48
  Number of hyperplanes created: 5070358
  Number of facets in hull: 4320576
  Number of distance tests for qhull: 1525377

error: voronoin: qhull failed
warning: voronoin: qhull did not free -2099969864 bytes of long memory (1 pieces)

我想我做错了什么,但我不知道是什么。我还查看了我可以提供的选项以及此处提供的 voronoin()

http://www.qhull.org/html/qh-quick.htm#options

但我似乎无法弄清楚他们是否会在这里帮助我

这是 50 个集群质心的链接

https://www.mediafire.com/?7flqqx66mmc4258

这是我正在运行的代码

C = dlmread('clust_centroids');
[Vc,Vf] = voronoin(C);

这给了我上面给出的错误。

【问题讨论】:

  • 您的问题有点宽泛,请坚持使用 python、matlab 或 octave 并在此处发布您的尝试。最好为您的代码提供示例数据,并说明您卡在哪里以及如何卡住。
  • 哦,当然,我添加了更多细节以及示例数据。如果我遗漏了什么,请告诉我,我会补充的。

标签: python matlab scipy octave voronoi


【解决方案1】:

如果您想在某个体积中生成随机点,只需选择一个包含该体积的笛卡尔对齐框,然后在框内随机创建点。检查它们是否在卷中,如果有则保留它们,否则丢弃它们。

关于你的第二个问题,我必须要问的是,你不是在这里重新发明了一个支持向量机吗?

【讨论】:

    【解决方案2】:

    我不明白您为什么要为 k-means 聚类算法执行此操作。您要生成一些样本进行测试吗?如果是这样,只需在整个空间内生成一些随机点,然后标记它们。

    如果您出于某种目的坚持在特定区域内生成一个点,那么无论您将 Voronoi 表示为位图还是矢量都将非常困难。我认为随机算法会有所帮助:

    Generate a random point p within the Voronoi region of centroid t
    1. generate a random point p within the entre space;
    2. compute the distance between p and each centroid;
    3. if the distance of p and t is the minimal distance, output p;
       else go to step 1.
    

    该算法的预期时间复杂度平均为O(n^2),并且很容易实现。虽然它的时间成本并不稳定。

    对于第二个问题,是的,有可能。考虑如果您在 3 维空间中有 2 个点,它们可以被平面雕刻成 2 个 Voronoi 区域。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-26
      • 2021-06-25
      • 1970-01-01
      • 1970-01-01
      • 2014-07-17
      相关资源
      最近更新 更多