function dataStatistic = computeDistributionStatistics(data, nBin)
% print some information on the selected point cloud

% common variables
nDim = size(data.hcMatrix, 1);
nSample = size(data.hcMatrix, 2);

%% projections onto all coordinate axes
% create bins
leftBnd = min(data.hcMatrix(:));
rightBnd = max(data.hcMatrix(:));
binBnd = linspace(leftBnd, rightBnd, nBin+1);
binBndLeft = binBnd(1:(end-1));
binBndRight = binBnd(2:end);
dataStatistic.binCenterVector = 0.5*binBndLeft + 0.5*binBndRight;

% fill bins
dataStatistic.binValueMatrix = zeros(nDim, nBin);
dataStatistic.assignedBinMatrix = nan(nDim, nSample);
for iDim = 1:size(data.hcMatrix, 1)
    filterMatrix = bsxfun(@ge, data.hcMatrix(iDim, :)', binBndLeft);
    filterMatrix = filterMatrix & ...
        bsxfun(@le, data.hcMatrix(iDim, :)', binBndRight);
    dataStatistic.binValueMatrix(iDim, :) = sum(double(filterMatrix), 1);
    for iBin = 1:nBin
        dataStatistic.assignedBinMatrix(iDim, filterMatrix(:, iBin)) = iBin;
    end
end
dataStatistic.binValueMatrix(dataStatistic.binValueMatrix(:)==0) = nan;
if any(isnan(dataStatistic.assignedBinMatrix(:))),error('nope');end


%% projection onto time axis
% create bin data
dataStatistic.timeVector = unique(data.timeVector);
dataStatistic.timeValueVector = zeros(1, length(dataStatistic.timeVector));
for iTime = 1:length(dataStatistic.timeVector)
    dataStatistic.timeValueVector(iTime) = sum(...
        data.timeVector == dataStatistic.timeVector(iTime));
end