%%
clear

N = 50;
A0 = [1; 0.1];
s = 1;
x = (1:N)';

X = [ones(size(x)) x];
%%
Ntestes = 100;
for qt = Ntestes : -1 : 1
    
    Y = X*A0 + s.*randn(size(x));
    [ A(:,qt), sA(:,qt), Q2(qt), NGL, VA{qt}, F(:,qt) ] = mmq_lin( X, Y, s );
    
end
% figure, plot( x, Y, '.', x, F, '-r' )
%%
x = (1:N)'; 
x = x-mean(x);
X = [ones(size(x)) x];
Ntestes = 100;
for qt = Ntestes : -1 : 1
    
    Y = X*A0 + s.*randn(size(x));
    [ A(:,qt), sA(:,qt), Q2(qt), NGL, VA{qt}, F(:,qt) ] = mmq_lin( X, Y, s );
    
end

%%
clear

N = 5000;
Ps = ones(10,1);
Ntestes = 1e3;
for qt = 1:Ntestes
    [ R ] = aleatorio_com_probabilidade( Ps, N );
    [ Y ] = hist( R, 1:10 );
    Y = Y(:);
    X = ones(size(Y));
    s = sqrt( (Y) );
    [A(qt),sA(qt), Q2(qt), NGL ] = mmq_lin( X, Y, s );
end

