function P = gaussdensity(rgb, train) MN = mean(train); CV = cov(train); coeff = 1 / ( (2*pi)^(3/2) * sqrt(norm(CV)) ); xMinusMN = rgb - repmat(MN, size(rgb,1), 1); EXPON1 = xMinusMN * inv(CV).'; EXPON2 = dot(xMinusMN.',EXPON1.'); EXPON3 = exp( (-1/2)*EXPON2 ); P = coeff*EXPON3; %EXPON3