nstates = 10;
nsyms = 28;

if(0)
a = abs(randn(nstates));
b = abs(randn(nstates, nsyms));
pi = abs(randn(1, nstates));
for i = 1:nstates
	a(i,:) = a(i,:)./sum(a(i,:));
	b(i,:) = b(i,:)./sum(b(i,:));
	pi = pi./sum(pi);
end
end
aahist = [];
abhist = [];
%achist = [];


%a = [ .7 .3; .3 .7];
%b = [ .6 .4; .4 .6];
%pi = [.5 .5];

a
b
pi

for seg = 1:25
segn = seg-1;
o1 = wb(((segn*100)+1):((segn*100)+101));
disp('Starting forward pass');
[P alpha] = hmmforward(a, pi, b, o1);
disp('Completed forward pass.  Starting backward pass');
beta = hmmbackward(a,pi,b,o1);
disp('Completed backward pass.  Updating parameters');
%gp = viterbi(a,pi,b,o1);
[na npi nb] = hmmlearn(a, pi, b, o1, alpha, beta);
a = (a+na)/2;
b = (b+nb)/2;
pi = (pi+npi)/2;
a
end




