Code covered by the BSD License  

Highlights from
Discriminant Analysis Programme

image thumbnail
from Discriminant Analysis Programme by Bartolomeu Rabacal
Discrimination and Classification of data to and from groups with classical/robust estimation

plotClassificationBoundaries(m_model, m_dap, classifyRuleCoefList, xyLim, xyInc)
function plotClassificationBoundaries(m_model, m_dap, classifyRuleCoefList, xyLim, xyInc)

% Plots the modeled concentration bounderies for the groups

xInc = xyInc(1);
yInc = xyInc(2);

if strcmp(m_model, 'linear') % The linear discriminant rule hasn't got the quadratic term nor the log generalized variance additive to the constant term so it has to be recomputed 
   noCV.D = 1;
   noCV.detD = 1;
   dummyData = m_dap.datasets.dataPerGroups{1}(1,:);
   for j = 1:m_dap.constants.numGrp
    [dummy, constCoef, linCoef, quadCoef] = quadraticRule(m_dap.meanList{j}, m_dap.modeledInvCovList.linear{1}, dummyData, ...
        m_dap.constants.aprioriProb(j), noCV);
    classifyRuleCoefList{j} = {constCoef, linCoef, quadCoef};
   end
end

for i = 1:m_dap.constants.numGrp
    hold on    
    C = classifyRuleCoefList{i}{1};
	L = classifyRuleCoefList{i}{2};
	Q = classifyRuleCoefList{i}{3};
    f = sprintf('%g + %g * x + %g * y + %g * x^2 + %g * x * y + %g * y^2', C, L(1), L(2), Q(1,1), Q(1,2) + Q(2,1), Q(2,2));
    ezplot(f, xyLim + [-xInc xInc -yInc yInc]);
end

Contact us at files@mathworks.com