function [A,B,Q] = HMM_MEDVED(O)

param = size(O,1);
Q = 11;

mu=zeros(param,Q);
vr=zeros(param,Q);
cv=zeros(param,param,Q);

%sil
mu(:,2) = [ -7.313049e+000 -9.398881e-001 -4.510057e-001 -7.288507e-001 -2.897759e-001 -7.751375e-002 -3.618123e-003 -1.390386e-001 2.084902e-001 -1.320959e-001 8.817019e-002 -1.228079e-001 6.917090e+001 -3.107722e-002 8.907292e-003 9.247836e-003 1.905289e-002 1.233459e-002 1.001064e-002 1.002233e-002 8.150973e-003 3.113299e-003 3.548607e-003 2.532211e-003 1.085190e-003 -1.025690e-001 7.951854e-003 -8.182072e-003 -6.170174e-003 -1.514464e-002 -6.019351e-003 -8.480256e-003 -3.986343e-003 -5.266401e-003 -1.843392e-003 -2.877901e-003 -8.476687e-004 -6.497114e-004 8.289810e-002]';
vr(:,2) = [3.163979e+000 2.168602e+000 1.371846e+000 1.517981e+000 9.038908e-001 8.897811e-001 6.909518e-001 5.652684e-001 5.599021e-001 5.125359e-001 4.591469e-001 4.670824e-001 3.629802e+001 1.388832e-001 9.953099e-002 7.722628e-002 7.820329e-002 6.347974e-002 6.216895e-002 5.599645e-002 5.214563e-002 4.893730e-002 4.565161e-002 4.265450e-002 4.052969e-002 8.744203e-001 2.787767e-002 2.031806e-002 1.623932e-002 1.644616e-002 1.327494e-002 1.286692e-002 1.156766e-002 1.087449e-002 1.014029e-002 9.546626e-003 8.929418e-003 8.537616e-003 1.812941e-001]';
cv(:,:,2) = diag(vr(:,2));
gconst(2) = -1.317014e+001;

%m
mu(:,3) = [-2.001450e+000 -2.442932e+000 -2.242260e+000 -4.685867e+000 -2.400244e+000 -3.707770e+000 -1.840339e+000 -1.288797e+000 -1.177366e+000 -6.033083e-001 -5.183871e-001 -5.150679e-001 9.362885e+001 -2.215655e-002 4.503697e-002 2.335700e-002 1.923463e-002 1.524961e-002 1.657869e-002 -1.704903e-002 -2.428291e-002 -2.924486e-003 -1.064218e-002 4.448599e-003 1.791724e-003 -2.397497e-001 -1.433038e-001 -1.026767e-001 -9.397433e-002 -1.082652e-002 3.533215e-002 8.512558e-002 5.272857e-002 -1.943383e-002 3.697251e-002 -2.622741e-002 1.557105e-002 4.762168e-003 5.158800e-001];
vr(:,3) = [5.861264e+000 6.624620e+000 3.281369e+000 3.236060e+000 2.336391e+000 2.582444e+000 2.260243e+000 1.784382e+000 1.448068e+000 1.314345e+000 1.258028e+000 1.110088e+000 1.154284e+002 5.104122e-001 6.173387e-001 3.524353e-001 2.472929e-001 1.722177e-001 2.650991e-001 1.703421e-001 1.342300e-001 1.095944e-001 9.458249e-002 8.096320e-002 6.767675e-002 8.108983e+000 8.125070e-002 8.915248e-002 4.909690e-002 3.822671e-002 2.985345e-002 3.635333e-002 2.785561e-002 2.436498e-002 1.947416e-002 1.747767e-002 1.557788e-002 1.280007e-002 7.511217e-001];
cv(:,:,3) = diag(vr(:,3));

%e
mu(:,4) = [-5.652693e+000 -4.615658e+000 -2.951687e+000 -6.895529e+000 -2.690160e+000 -1.732640e+000 -4.101386e-001 -1.908145e+000 4.470546e-002 -1.065471e+000 -5.548403e-001 -4.460121e-001 1.102027e+002 2.847615e-001 1.058228e-001 5.352417e-002 3.017063e-002 -6.559902e-002 -2.231777e-002 -4.896455e-002 -2.233832e-002 -5.249316e-002 -6.145196e-004 -3.299612e-002 -1.492214e-002 -5.427094e-001 -6.388226e-002 1.414389e-001 5.564144e-002 1.609482e-001 6.562461e-002 -5.549205e-003 -2.051019e-003 5.329981e-002 -9.825671e-003 2.160343e-002 2.673190e-002 3.019699e-003 -1.050667e+000];
vr(:,4) = [1.016467e+001 8.372550e+000 3.267163e+000 3.284851e+000 3.946333e+000 2.220042e+000 1.971026e+000 1.683012e+000 1.512034e+000 1.961291e+000 1.249286e+000 1.248523e+000 1.649046e+002 9.557528e-001 7.732920e-001 2.755146e-001 4.788254e-001 2.462779e-001 1.959681e-001 1.378614e-001 1.330008e-001 1.054550e-001 1.039458e-001 9.952246e-002 8.163809e-002 2.124301e+001 1.870248e-001 1.010609e-001 4.240693e-002 5.646939e-002 4.331052e-002 3.720109e-002 2.576043e-002 2.202496e-002 1.933648e-002 1.898772e-002 1.799011e-002 1.529474e-002 1.844348e+000];
cv(:,:,4) = diag(vr(:,4));

%d
mu(:,5) = [-4.034159e+000 -1.900170e+000 -1.541635e+000 -3.994078e+000 -2.621357e+000 -2.345720e+000 -7.552631e-001 -1.370428e+000 -5.220966e-001 -7.317654e-001 -2.746222e-001 -4.276884e-001 8.902534e+001 -2.684382e-001 -1.185266e-001 -1.828940e-002 -4.905635e-002 5.971956e-002 1.660286e-002 2.853787e-002 3.457754e-002 5.733160e-002 1.420415e-003 2.818370e-002 -7.067057e-003 3.670285e-001 -3.032194e-002 -2.169647e-001 -1.961219e-001 -1.247110e-001 -1.067427e-002 -3.142693e-002 3.483187e-002 1.692716e-002 2.482890e-002 -6.740572e-003 -7.124381e-003 -1.019700e-002 1.407841e+000];
vr(:,5) = [1.233985e+001 8.963035e+000 3.303512e+000 4.207277e+000 2.776354e+000 2.723218e+000 1.922005e+000 1.573160e+000 1.536983e+000 1.212703e+000 9.585491e-001 8.550408e-001 1.793605e+002 1.333360e+000 1.074278e+000 5.174479e-001 5.895388e-001 2.912492e-001 2.566878e-001 2.140373e-001 1.563514e-001 1.657646e-001 1.098119e-001 9.649910e-002 8.229946e-002 3.024328e+001 2.971724e-001 1.587554e-001 8.127194e-002 1.035212e-001 5.908025e-002 4.395216e-002 3.784664e-002 2.966987e-002 3.326592e-002 2.158533e-002 1.953725e-002 1.601071e-002 3.665768e+000];
cv(:,:,5) = diag(vr(:,5));

%v
mu(:,6) = [-1.895744e+000 -4.723778e+000 -4.225591e+000 -4.245115e+000 -2.536538e+000 -3.076726e+000 -1.018079e+000 -4.893140e-001 -4.442267e-001 -7.698113e-001 -2.498743e-001 -5.560810e-001 9.892397e+001 -6.579948e-002 -7.506600e-003 9.232078e-003 -7.079560e-002 1.235701e-002 7.030297e-003 -1.312185e-003 -9.887345e-003 -3.183968e-003 1.354824e-003 4.539925e-003 3.568187e-003 1.891091e-001 -1.239767e-001 -5.011826e-002 -1.424538e-002 -6.770749e-002 1.768354e-002 1.772602e-002 2.555358e-002 -3.334050e-002 -4.845366e-003 -9.191507e-004 -4.150939e-003 3.475745e-003 5.579350e-001];
vr(:,6) = [7.833885e+000 9.748186e+000 7.385983e+000 3.086403e+000 2.620571e+000 1.784847e+000 2.067765e+000 1.572667e+000 1.406217e+000 1.120886e+000 1.036178e+000 8.155455e-001 1.850462e+002 4.396904e-001 5.372608e-001 3.100377e-001 2.410554e-001 1.452841e-001 1.346129e-001 1.295327e-001 9.896201e-002 8.847342e-002 7.322238e-002 5.967746e-002 5.365814e-002 1.030069e+001 6.908977e-002 7.954191e-002 4.844787e-002 3.790684e-002 2.409670e-002 2.368775e-002 2.116424e-002 1.793876e-002 1.598990e-002 1.366927e-002 1.159776e-002 1.036331e-002 1.539998e+000];
cv(:,:,6) = diag(vr(:,6));

%j
mu(:,7) = [-6.273920e+000 -1.338898e+000 -3.253977e+000 -7.794551e+000 -2.143272e+000 -3.007645e+000 -8.752909e-001 -1.234140e+000 -1.091572e-001 -9.250275e-001 -2.451839e-001 -6.878191e-001 1.087950e+002 -1.842430e-002 1.316805e-001 -2.081253e-002 -4.171484e-002 2.414002e-002 -2.276024e-002 -1.379517e-002 -1.624038e-002 4.266783e-003 -5.670819e-003 -2.306682e-003 4.431725e-003 -5.433547e-002 5.946684e-002 -4.158941e-002 2.939960e-002 8.273286e-002 -1.841283e-002 1.303121e-002 1.607404e-003 -6.891978e-003 -6.952472e-003 4.650649e-003 -1.740487e-003 7.567830e-003 -3.479032e-001];
vr(:,7) = [8.500678e+000 1.473379e+001 4.285209e+000 3.146798e+000 3.645571e+000 2.722802e+000 2.509467e+000 1.447940e+000 1.125164e+000 1.334180e+000 1.302514e+000 1.268488e+000 1.621912e+002 2.689691e-001 4.402932e-001 1.608462e-001 2.042360e-001 1.185476e-001 1.390297e-001 9.515630e-002 6.897902e-002 5.729495e-002 5.852387e-002 5.901338e-002 5.341962e-002 4.449862e+000 4.708724e-002 4.627082e-002 2.594119e-002 3.332618e-002 2.087559e-002 2.200909e-002 1.574084e-002 1.200167e-002 1.042531e-002 1.012447e-002 9.931801e-003 9.405447e-003 5.139021e-001];
cv(:,:,7) = diag(vr(:,7));

%e
mu(:,8) = [-5.652693e+000 -4.615658e+000 -2.951687e+000 -6.895529e+000 -2.690160e+000 -1.732640e+000 -4.101386e-001 -1.908145e+000 4.470546e-002 -1.065471e+000 -5.548403e-001 -4.460121e-001 1.102027e+002 2.847615e-001 1.058228e-001 5.352417e-002 3.017063e-002 -6.559902e-002 -2.231777e-002 -4.896455e-002 -2.233832e-002 -5.249316e-002 -6.145196e-004 -3.299612e-002 -1.492214e-002 -5.427094e-001 -6.388226e-002 1.414389e-001 5.564144e-002 1.609482e-001 6.562461e-002 -5.549205e-003 -2.051019e-003 5.329981e-002 -9.825671e-003 2.160343e-002 2.673190e-002 3.019699e-003 -1.050667e+000];
vr(:,8) = [1.016467e+001 8.372550e+000 3.267163e+000 3.284851e+000 3.946333e+000 2.220042e+000 1.971026e+000 1.683012e+000 1.512034e+000 1.961291e+000 1.249286e+000 1.248523e+000 1.649046e+002 9.557528e-001 7.732920e-001 2.755146e-001 4.788254e-001 2.462779e-001 1.959681e-001 1.378614e-001 1.330008e-001 1.054550e-001 1.039458e-001 9.952246e-002 8.163809e-002 2.124301e+001 1.870248e-001 1.010609e-001 4.240693e-002 5.646939e-002 4.331052e-002 3.720109e-002 2.576043e-002 2.202496e-002 1.933648e-002 1.898772e-002 1.799011e-002 1.529474e-002 1.844348e+000];
cv(:,:,8) = diag(vr(:,8));

%t
mu(:,9) = [-7.208775e+000 -2.128878e+000 -1.491686e+000 -2.306034e+000 -9.306970e-001 -6.910073e-001 1.465797e-001 -3.150415e-001 2.986292e-001 -2.449950e-001 1.263141e-001 -2.307333e-001 7.926539e+001 -3.104926e-001 -4.240009e-001 -1.393546e-001 -2.006556e-001 7.786492e-004 -2.032149e-002 8.318166e-002 -2.424081e-002 5.541204e-002 -1.596023e-003 3.556936e-002 5.274592e-003 2.127047e+000 1.348466e-001 -1.100651e-001 -1.120094e-001 -1.664526e-001 -1.052370e-001 -1.148193e-001 -3.461311e-002 -6.156218e-002 -3.678568e-002 -3.170031e-002 -2.947961e-002 -1.312791e-002 1.346656e+000];
vr(:,9) = [1.165793e+001 7.131843e+000 2.754029e+000 3.039163e+000 1.778857e+000 1.411700e+000 1.144242e+000 1.014023e+000 9.211938e-001 7.235847e-001 6.359264e-001 5.506881e-001 1.281812e+002 1.703206e+000 8.919994e-001 3.660102e-001 5.559947e-001 3.138480e-001 2.746967e-001 1.491224e-001 1.668051e-001 1.217634e-001 9.601240e-002 8.232007e-002 6.653140e-002 2.708702e+001 3.460378e-001 1.672539e-001 5.545076e-002 6.674270e-002 4.437287e-002 3.314702e-002 2.723271e-002 2.662940e-002 2.367432e-002 1.784931e-002 1.689554e-002 1.344289e-002 3.305375e+000];
cv(:,:,9) = diag(vr(:,9));

%sil
mu(:,10) = [ -7.313049e+000 -9.398881e-001 -4.510057e-001 -7.288507e-001 -2.897759e-001 -7.751375e-002 -3.618123e-003 -1.390386e-001 2.084902e-001 -1.320959e-001 8.817019e-002 -1.228079e-001 6.917090e+001 -3.107722e-002 8.907292e-003 9.247836e-003 1.905289e-002 1.233459e-002 1.001064e-002 1.002233e-002 8.150973e-003 3.113299e-003 3.548607e-003 2.532211e-003 1.085190e-003 -1.025690e-001 7.951854e-003 -8.182072e-003 -6.170174e-003 -1.514464e-002 -6.019351e-003 -8.480256e-003 -3.986343e-003 -5.266401e-003 -1.843392e-003 -2.877901e-003 -8.476687e-004 -6.497114e-004 8.289810e-002]';
vr(:,10) = [3.163979e+000 2.168602e+000 1.371846e+000 1.517981e+000 9.038908e-001 8.897811e-001 6.909518e-001 5.652684e-001 5.599021e-001 5.125359e-001 4.591469e-001 4.670824e-001 3.629802e+001 1.388832e-001 9.953099e-002 7.722628e-002 7.820329e-002 6.347974e-002 6.216895e-002 5.599645e-002 5.214563e-002 4.893730e-002 4.565161e-002 4.265450e-002 4.052969e-002 8.744203e-001 2.787767e-002 2.031806e-002 1.623932e-002 1.644616e-002 1.327494e-002 1.286692e-002 1.156766e-002 1.087449e-002 1.014029e-002 9.546626e-003 8.929418e-003 8.537616e-003 1.812941e-001]';
cv(:,:,10) = diag(vr(:,10));
gconst(10) = -1.317014e+001;


A = [
    0.000000e+000 1.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000;
    0.000000e+000 9.649747e-001 3.502526e-002 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000;
    0.000000e+000 0.000000e+000 8.511369e-001 1.488632e-001 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000;
    0.000000e+000 0.000000e+000 0.000000e+000 8.426186e-001 1.573814e-001 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000;
    0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 7.964817e-001 2.035183e-001 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000;
    0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 8.205819e-001 1.794181e-001 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000;
    0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 8.679487e-001 1.320513e-001 0.000000e+000 0.000000e+000 0.000000e+000;
    0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 8.426186e-001 1.573814e-001 0.000000e+000 0.000000e+000;
    0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 8.444298e-001 1.555702e-001 0.000000e+000;
    0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 9.649747e-001 3.502526e-002;
    0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000;
    ];

B=zeros(Q,size(O,2));

for i = 1 : size(O,2)
    o = O(:,i);
    for j = 2 : Q-1
        B(j,i) =  (1/((((2*pi)^param)*det(cv(:,:,j)))^(1/2)))*exp(-0.5*(o-mu(:,j))'*inv(cv(:,:,j))*(o-mu(:,j)));
    end
end
