计算Matlab中2D点列表的熵 [英] Calculate the entropy of a list of 2D points in Matlab
问题描述
我在这样的数组中有一个点列表
points = [[1,2]; [2,5]; [7,1] ... [x,y]]
x在0到1020之间,y在0到1920之间.
如何在Matlab中计算点数组的熵?
非常感谢!
我假设您想将每个 [x,y]
点视为一个数据点.让我们定义一些示例性数据: A = [[1,2]; [2,5]; [7,1]; [1,2]];
首先我们给相等的点相等的标识符,我们可以使用
[〜,〜,ic] = unique(A,'rows');
然后我们计算频率以及每个标识符的概率:
[frequency,〜] = histcounts(ic,max(ic));概率=频率/总和(频率);
有了这个,我们可以立即计算熵:
熵= -sum(概率.* log(概率))
(请确保使用正确的对数,传统上不同的字段使用不同的底数.)
I have a list of points in an array like this
points = [[1,2];[2,5];[7,1]...[x,y]]
The x is between 0 and 1020 and y is between 0 and 1920.
How can I calculate the entropy of the points array in Matlab?
Many thanks!
I assume you want to consider each [x,y]
point as one data point. Let us define some exemplary data:
A = [[1,2];[2,5];[7,1];[1,2]];
First we give equal points equal identifiers, we can do this using
[~,~,ic] = unique(A, 'rows');
Then we compute the frequency and with that the probability of each identifier:
[frequency, ~] = histcounts(ic,max(ic));
probability = frequency/sum(frequency);
With this we can immediately compute the entropy:
entropy = -sum(probability .* log(probability))
(Make sure you use the right logarithm, different fields conventionally use different bases.)
这篇关于计算Matlab中2D点列表的熵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!