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

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

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

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;

mu(:,3) = [ -6.545323e+000 -3.892320e+000 -1.636953e+000 -2.222779e+000 -1.014096e+000 -9.023929e-001 1.103083e-003 -2.985399e-001 1.321728e-001 -2.284619e-001 5.709594e-002 -2.461104e-001 8.240534e+001 -1.893980e-002 -3.273061e-001 -1.775057e-001 -6.073304e-002 4.163495e-002 -4.962487e-002 3.911957e-002 3.734658e-002 3.037159e-002 -1.502426e-002 9.716090e-003 1.767162e-002 1.140246e+000 1.125629e-001 -1.703891e-002 -9.927938e-002 -1.330571e-001 -5.118115e-002 -7.256605e-002 -4.440103e-002 -3.517200e-002 -2.585248e-002 -2.186541e-002 -1.990273e-002 -1.605375e-002 8.911036e-001];
vr(:,3) = [1.270238e+001 1.381968e+001 5.881086e+000 5.416528e+000 2.727337e+000 2.071733e+000 1.482240e+000 1.328801e+000 1.007770e+000 7.911476e-001 6.821217e-001 5.817094e-001 1.626822e+002 1.510991e+000 1.742701e+000 5.902455e-001 7.072293e-001 3.172706e-001 2.990301e-001 1.996341e-001 1.575205e-001 1.155321e-001 9.620684e-002 8.330090e-002 7.047909e-002 2.746779e+001 2.696688e-001 3.676652e-001 9.530207e-002 9.549393e-002 5.675465e-002 4.484101e-002 3.335138e-002 2.812197e-002 2.218434e-002 1.852601e-002 1.630673e-002 1.398936e-002 4.171160e+000];
cv(:,:,3) = diag(vr(:,3));

mu(:,4) = [-2.077660e+000 -5.943670e+000 -5.619095e+000 -3.970376e+000 -2.300948e+000 -3.193937e+000 -5.405280e-001 -6.173729e-001 -2.782240e-001 -1.025004e+000 -4.223464e-001 -5.536336e-001 1.048845e+002 2.481232e-001 2.380227e-001 2.343757e-002 -4.793472e-003 -1.007345e-001 -8.967271e-002 -8.159436e-002 -2.947651e-002 -5.043452e-002 -2.403574e-002 -3.524349e-002 -3.222278e-002 -2.256212e-001 -2.169646e-001 1.886567e-001 2.033907e-001 6.488508e-002 5.190995e-002 8.473147e-002 7.982724e-003 -5.154938e-003 1.239212e-002 3.178590e-002 1.669582e-002 1.047845e-002 -1.028436e+000];
vr(:,4) = [1.003157e+001 7.110540e+000 6.175197e+000 2.996074e+000 2.943091e+000 2.364480e+000 2.402321e+000 2.101370e+000 1.451301e+000 1.196608e+000 1.028480e+000 9.830235e-001 1.746975e+002 1.328967e+000 9.059880e-001 1.020386e+000 3.343944e-001 2.310837e-001 2.622339e-001 1.925851e-001 1.550811e-001 1.193967e-001 1.114187e-001 9.716111e-002 8.393103e-002 2.191437e+001 2.028668e-001 1.234960e-001 1.171156e-001 5.406774e-002 4.283670e-002 4.009138e-002 3.749999e-002 2.948771e-002 2.371191e-002 2.061919e-002 1.876946e-002 1.656367e-002 2.170150e+000];
cv(:,:,4) = diag(vr(:,4));

mu(:,5) = [1.621377e+000 -4.453452e-001 -1.787026e+000 -3.078322e+000 -2.697741e+000 -2.739373e+000 -1.753876e+000 -1.332573e+000 -9.848484e-001 -9.055177e-001 -4.246274e-001 -4.549552e-001 8.127512e+001 -3.696124e-001 -1.375416e-001 1.162721e-001 -7.313237e-002 5.519211e-002 5.416070e-002 6.255484e-002 -5.232111e-003 4.066866e-002 4.605709e-003 2.537220e-002 -3.037072e-003 5.182204e-001 -1.652412e-001 -2.649247e-001 -1.453421e-001 -1.970941e-001 1.437897e-003 -2.796310e-002 6.620608e-002 2.193618e-002 4.980065e-002 1.363773e-002 8.935463e-003 -1.357568e-002 1.772392e+000];
vr(:,5) = [6.668507e+000 5.238743e+000 2.839279e+000 2.149852e+000 1.560984e+000 1.739775e+000 1.631311e+000 1.349365e+000 1.256409e+000 1.047792e+000 9.201391e-001 7.781480e-001 6.779091e+001 7.437097e-001 1.128874e+000 3.997987e-001 4.907404e-001 1.643707e-001 1.668303e-001 1.890328e-001 1.333354e-001 1.328436e-001 9.759200e-002 7.807993e-002 6.866559e-002 2.478067e+001 1.470881e-001 1.347253e-001 5.939887e-002 5.308220e-002 3.089979e-002 3.298876e-002 3.045420e-002 2.572247e-002 2.288560e-002 1.889402e-002 1.561905e-002 1.358917e-002 1.725672e+000];
cv(:,:,5) = diag(vr(:,5));

mu(:,6) = [-5.692218e+000 -1.056079e+000 -2.210369e+000 -7.478284e+000 -2.485191e+000 -2.902896e+000 -1.287098e+000 -1.200753e+000 3.079682e-002 -8.104677e-001 -3.032473e-001 -5.948021e-001 1.023359e+002 1.664821e-001 1.416075e-001 5.723488e-002 7.727101e-002 -2.241412e-002 1.078036e-002 -3.417325e-002 3.740221e-003 -1.769172e-002 -1.337926e-004 -2.640491e-002 -5.555181e-003 -8.091910e-001 -5.492649e-002 -3.252365e-002 1.998989e-002 1.821315e-001 5.015554e-002 4.990844e-002 4.287278e-002 2.172364e-002 -6.513575e-003 1.342024e-002 1.176285e-002 1.026329e-002 -6.737263e-001];
vr(:,6) = [9.066644e+000 7.997166e+000 4.253278e+000 4.385633e+000 3.317510e+000 1.946542e+000 2.009478e+000 1.268801e+000 1.177719e+000 1.437117e+000 1.088291e+000 1.221777e+000 2.008504e+002 9.083863e-001 4.478580e-001 2.912616e-001 7.511019e-001 2.370359e-001 2.204838e-001 1.471695e-001 1.073522e-001 9.671926e-002 8.724972e-002 8.683947e-002 8.283613e-002 1.780736e+001 1.645788e-001 7.778298e-002 5.009342e-002 8.410279e-002 4.135911e-002 3.688188e-002 2.558327e-002 1.968217e-002 1.834163e-002 1.642259e-002 1.607905e-002 1.526332e-002 2.050935e+000];
cv(:,:,6) = diag(vr(:,6));

mu(:,7) = [-3.138562e+000 -7.563502e+000 -5.290282e+000 -4.376231e+000 -2.091170e+000 -3.047654e+000 1.485340e-001 -8.863717e-001 -8.229234e-001 -1.056014e+000 -3.115347e-001 -3.907134e-001 1.126714e+002 7.114074e-002 2.502333e-002 -1.903201e-003 -1.097897e-002 -3.367439e-002 1.508203e-002 -6.131828e-004 -3.937151e-002 -1.496601e-002 8.862166e-003 -1.250381e-002 2.699794e-003 5.581088e-002 -4.953837e-002 1.082374e-001 7.827281e-002 6.524385e-003 5.559986e-003 3.333310e-002 -3.278174e-002 -1.276414e-002 2.668585e-002 1.384303e-002 -2.438150e-004 1.439625e-003 -4.991049e-001];
vr(:,7) = [7.957896e+000 5.985745e+000 5.029407e+000 3.139295e+000 3.380268e+000 2.804773e+000 2.255632e+000 2.815910e+000 1.662203e+000 1.213570e+000 1.003155e+000 1.022846e+000 1.342358e+002 3.952126e-001 4.495636e-001 2.976177e-001 2.014607e-001 1.734050e-001 1.758243e-001 1.295988e-001 1.152960e-001 1.039754e-001 8.132098e-002 6.836876e-002 5.616666e-002 6.967901e+000 7.364866e-002 5.511713e-002 3.916116e-002 3.259997e-002 2.821364e-002 3.241866e-002 2.274641e-002 1.881221e-002 1.772779e-002 1.452828e-002 1.248858e-002 1.058102e-002 7.020664e-001];
cv(:,:,7) = diag(vr(:,7));

mu(:,8) = [ -6.545323e+000 -3.892320e+000 -1.636953e+000 -2.222779e+000 -1.014096e+000 -9.023929e-001 1.103083e-003 -2.985399e-001 1.321728e-001 -2.284619e-001 5.709594e-002 -2.461104e-001 8.240534e+001 -1.893980e-002 -3.273061e-001 -1.775057e-001 -6.073304e-002 4.163495e-002 -4.962487e-002 3.911957e-002 3.734658e-002 3.037159e-002 -1.502426e-002 9.716090e-003 1.767162e-002 1.140246e+000 1.125629e-001 -1.703891e-002 -9.927938e-002 -1.330571e-001 -5.118115e-002 -7.256605e-002 -4.440103e-002 -3.517200e-002 -2.585248e-002 -2.186541e-002 -1.990273e-002 -1.605375e-002 8.911036e-001];
vr(:,8) = [1.270238e+001 1.381968e+001 5.881086e+000 5.416528e+000 2.727337e+000 2.071733e+000 1.482240e+000 1.328801e+000 1.007770e+000 7.911476e-001 6.821217e-001 5.817094e-001 1.626822e+002 1.510991e+000 1.742701e+000 5.902455e-001 7.072293e-001 3.172706e-001 2.990301e-001 1.996341e-001 1.575205e-001 1.155321e-001 9.620684e-002 8.330090e-002 7.047909e-002 2.746779e+001 2.696688e-001 3.676652e-001 9.530207e-002 9.549393e-002 5.675465e-002 4.484101e-002 3.335138e-002 2.812197e-002 2.218434e-002 1.852601e-002 1.630673e-002 1.398936e-002 4.171160e+000];
cv(:,:,8) = diag(vr(:,8));

mu(:,9) = [-4.481637e+000 -8.077502e+000 -4.016692e+000 -3.959216e+000 -1.943099e+000 -1.942464e+000 -5.334513e-002 -1.779836e+000 -9.108570e-001 -8.647965e-001 -1.575557e-001 -3.417000e-001 1.108569e+002 1.572965e-001 1.522747e-001 3.694922e-002 6.427733e-002 -1.576646e-002 2.460924e-003 -4.861242e-002 -8.977579e-003 -2.786925e-002 -1.844933e-003 -7.239067e-003 -6.211887e-003 -7.288184e-001 -5.171122e-002 2.275510e-001 9.396244e-002 3.644866e-002 2.680325e-002 8.704010e-003 -1.878852e-002 3.775245e-002 2.848845e-002 1.600545e-002 3.224804e-003 4.063338e-004 -1.001832e+000];
vr(:,9) = [1.090561e+001 9.380291e+000 4.552089e+000 4.492853e+000 3.058557e+000 2.528795e+000 2.069547e+000 2.826441e+000 1.757432e+000 1.402670e+000 1.125660e+000 1.032359e+000 2.222020e+002 7.745796e-001 1.412038e+000 4.231963e-001 3.036933e-001 1.844625e-001 1.880224e-001 1.470821e-001 1.549169e-001 1.284645e-001 1.011812e-001 8.199082e-002 6.975959e-002 2.564225e+001 1.581634e-001 1.436237e-001 5.938128e-002 5.372630e-002 3.572884e-002 3.539442e-002 2.820129e-002 2.596946e-002 2.251661e-002 1.860138e-002 1.593943e-002 1.345356e-002 2.273973e+000];
cv(:,:,9) = diag(vr(:,9));

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.789026e-001 1.210974e-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.323556e-001 1.676444e-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.347217e-001 1.652783e-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.696927e-001 1.303072e-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.639915e-001 1.360085e-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.789026e-001 1.210974e-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.722202e-001 1.277798e-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

    