我有以下给我的代码,但我完全不确定这里的逻辑是什么。我相信这个想法是这将对我的数据进行直方图/量化。这是代码:
输入:
x = 180.*rand(1,1000); %1000 points from 0 to 180 degrees.
binWidth = 20; %I want the binWidth to be 20 degrees.
主要功能:
% -------------------------------------------------------------------------
% Compute the closest bin center x1 that is less than or equal to x
% -------------------------------------------------------------------------
function [x1, b1] = computeLowerHistBin(x, binWidth)
% Bin index
bin = floor(x./binWidth - 0.5);
% Bin center x1
x1 = binWidth * (bin + 0.5);
% add 2 to get to 1-based indexing
b1 = bin + 2;
end
最后,最终的“量化”数据:
w = 1 - (x - x1)./binWidth
这是我不明白的:我不明白 - 根本 - 究竟为什么要按x1
原样计算,以及为什么/如何w
按原样计算。事实上,在所有事情中,w
最让我困惑的是。我真的无法理解这里的逻辑,或者真正的意图。希望能详细说明这个逻辑。谢谢。