% BAYES regression - using linear equation

%% first we generate the data
w     = rand(2,1);
x     = [-1:0.01:1];
s_dev = 0.1;

y = [x' ones(201,1)]*w + randn(201,1)*s_dev;
plot(x,y,'rx');

% We assume next that the values in vector W are unknown BUT we keep it
% for REFERENCE

%% our problem is to find w_inf - the values of the inferred parameters

% in this setting w_inf is a RANDOM VARIABLE with Gaussian distribution
% with mean m_w and variance s_w
% The problem is to find the parameters of the distribution: m_m and s_v

% We have to write BAYES' formula

% Have to compute the POSTERIOR distribution

% The POSTERIOR DISTRIBUTION of w_inf is a two-dimensional GAUSSIAN

% We generate 20 examples

% We draw the equations
for ii = 1:20;
    w_inf = wVect(:,ii);
    y     = [x' ones(201,1)]*w_inf;
    plot(x,y);
end;
