I have been converting some Matlab code into Python. I have been debugging this program for a while and I am wondering if I am correct in the way I am thinking about the arrays in Matlab.
I have this code in Matlab (edited to add missing variables and executions):
pdf_pars = pdf_pars(1)*ones(1,p);
weights = 1;
% determine the size of each lenght
mode_length = round(weights*samp_size);
% correct for rounding erros
mode_length(no_modes) = mode_length(no_modes) + samp_size - sum(mode_length) ;
for i=1:no_modes
x = [x dirichlet(pdf_pars(i,:),mode_length(i))'];
end
When you read the first line, it seemed to me like mode_length was an integer (or perhaps a double). However the next line starts indexing. I know that in Python, this treatment of mode_length will cause an error.
Am I interpreting this Matlab code correctly? And how can I work around this as I continue moving code into Python?
weights,samp_size, andno_modes?weightsis a vector, andsamp_sizeis a scalar.weightsandsamp_sizeare both scalars (which I'm skeptical is the case), thenmode_lengthwill be a scalar. The reason for my skepticism is because you then try to indexmode_lengthin the following line...no_modesbecause this is the index you are trying to query