function qdata = quantize(cdata, numBins)

% cuantize the given data in the selected number of bins
%
% qdata = quantize(cdata, numBins)
% 
% cdata(i,j) is the real-valued i'th timestep for variable j
% numBins is an integer >= 1
% qdata(i,j) is the integer value on interval [1,numBins] for the
%            i'th timestep for variable j
%
% Find the min and max for each timeseries, then linearly space boundaries

% APRENDIZAJE AUTOMÁTICO (G. Pajares y J. M. de la Cruz, Eds.)
% Editorial: RA-MA
% Capítulo 6: Redes Bayesianas
% Autores: Diane Oyen, Eva Besada-Portas

[T N] = size(cdata);

maxData = max(cdata);
minData = min(cdata);
normData = (cdata - repmat(minData, T, 1)) ./ repmat((maxData - minData), T, 1);
qdata = ceil(normData * numBins);
qdata(qdata==0) = 1;