function [number, loglikness]= MGStestiranje (testni)

% %TESTIRANJE IZRAVNO
% source1IO;
% 
% testni=ans;
 for j=2:36
        y_dist = testni(j,2)-testni(j-1,2);
        x_dist = testni(j,1)-testni(j-1,1);
        if x_dist == 0
            x_dist = 0.00000001;
        end
        a = atand(y_dist/x_dist)+0.01;
        if y_dist < 0 && x_dist > 0
            a = a + 360;
        elseif (y_dist < 0 && x_dist < 0) || (y_dist > 0 && x_dist < 0)
            a = a + 180;
        end
        
        testdata = round(a/20);
        if testdata == 0
            testdata = 1;
        elseif testdata == -4
            testdata = 14;
        end
        
          podataktocan(1,j-1)=testdata;
          podataktocan(2,j-1)=testni(j,3);
            
            if podataktocan(2,j-1)>5
                podataktocan(2,j-1)=5;
            end
            if podataktocan(2,j-1)==0
                podataktocan(2,j-1)=6;
            end

        
    end


%modificiranje testdata u podataktocan (MGP, MGS, DP ili DS)
% testnibroj=6;  
%     
%     for j=2:36
%         y_dist = testni{testnibroj}(j,2)-testni{testnibroj}(j-1,2);
%         x_dist = testni{testnibroj}(j,1)-testni{testnibroj}(j-1,1);
%         if x_dist == 0
%             x_dist = 0.00000001;
%         end
%         a = atand(y_dist/x_dist)+0.01;
%         if y_dist < 0 && x_dist > 0
%             a = a + 360;
%         elseif (y_dist < 0 && x_dist < 0) || (y_dist > 0 && x_dist < 0)
%             a = a + 180;
%         end
%         
%         testdata = round(a/20);
%         if testdata == 0
%             testdata = 1;
%         elseif testdata == -4
%             testdata = 14;
%         end
%         
%           podataktocan(1,j-1)=testdata;
%           podataktocan(2,j-1)=testni{testnibroj}(j,3);
%             
%             if podataktocan(2,j-1)>5
%                 podataktocan(2,j-1)=5;
%             end
%             if podataktocan(2,j-1)==0
%                 podataktocan(2,j-1)=6;
%             end
% 
%         
%     end


%%TESTIRANJE%%
MAXloglik = -Inf;
number=0;

% use model to compute log likelihood
for i = 1:8
    if isempty(prior{i}) == 0
        %loglikness{testnb}(i,Q) = dhmm_logprob(testdata, prior{i}, transmat{i}, obsmat{i});
        loglikness(i) = mhmm_logprob(podataktocan, prior{i}, transmat{i}, mu{i}, Sigma{i}, mixmat{i});
        if loglikness(i) > MAXloglik
            MAXloglik = loglikness(i);
            number = i;
        end
    end
end

% %ISPIS REZULTATA
% switch number
%     case 1
%         disp('gledaj');
%     case 2
%         disp('grc');
%     case 3
%         disp('idem gori');
%     case 4
%         disp('nestaje mi zraka');
%     case 5
%         disp('okreni se');
%     case 6
%         disp('opasnost');
%     case 7
%         disp('smiri se');
%     case 8
%         disp('stani');
%     otherwise
%         disp('brate ne znam kako si uspio dobiti ovo rjesenje');
% end
% 
% figure(1)
% bar( [1 2 3 4 5 6 7 8], loglikness(:))
% set(gca, 'XTick', [1:8], 'XGrid', 'On', 'XLim', [0 9])

end