简体   繁体   English

计算 Matlab 中二维点列表的熵

[英]Calculate the entropy of a list of 2D points in Matlab

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. x 介于 0 和 1020 之间,y 介于 0 和 1920 之间。

How can I calculate the entropy of the points array in Matlab?如何计算 Matlab 中点数组的熵?

Many thanks!非常感谢!

I assume you want to consider each [x,y] point as one data point.我假设您想将每个[x,y]点视为一个数据点。 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.) (确保使用正确的对数,不同的字段通常使用不同的底数。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM