clear all;
close all;


x_points = [-12:0.2:30];

m_1 = 0; s_1 = 10; 
m_2 = 6; s_2 = 6;
% m_1 = 0; m_2 = 3;
% s_1 = 9; s_2 = 4;
p_xw1 = pdf('Normal',x_points,m_1,sqrt(s_1));
p_xw2 = pdf('Normal',x_points,m_2,sqrt(s_2));

% f = inline('1/(sqrt(2*pi*s)) .* exp(-(x - m).^2 / (2 * s))','x','m','s');
% f2 = inline('1/(sqrt(2*pi*3)) .* exp(-(x-10).^2 / (2 * 3))','x','m_2','s_2');

figure;
hold on;
plot(x_points,p_xw1,'blue')
plot(x_points,p_xw2,'red')
% plot(x_points,f(x_points,m_1,s_1),':b');
% plot(x_points,f(x_points,m_2,s_2),':r');
xlim([x_points(1) x_points(end)]);
max_p = max([p_xw1 p_xw2]);
ylim([0 max_p]);
ylabel('p');
xlabel('x');
legend('p(x|w_1)','p(x|w_2)');

sols = roots([8 -240 720]);
line([sols([1 1],1)], [0;max_p],'color','g');
line([sols([2 2],1)], [0;max_p],'color','g');

text(-7,0.1,'R_1');
text(15,0.1,'R_2');
text(28,0.1,'R_1');

