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

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

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) = [-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));

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) = [-5.138490e+000 -6.607156e+000 -2.764356e+000 -5.735899e+000 -3.267683e+000 -2.423122e+000 4.363049e-001 -1.331548e+000 -4.696270e-001 -6.273233e-001 -3.636466e-001 -6.644976e-001 1.106756e+002 2.414295e-001 -1.105582e-001 -1.015936e-001 -1.310272e-001 -1.201383e-001 -1.162828e-001 -3.604801e-002 -3.710509e-002 -5.636860e-002 -4.598598e-002 -2.952433e-002 -2.881427e-002 1.173055e+000 1.049023e-002 1.264918e-001 6.174608e-004 1.053397e-001 7.455110e-002 2.481753e-002 -4.897345e-002 2.940289e-002 1.569034e-002 -1.151004e-003 1.006300e-002 1.720161e-002 -7.341132e-001];
vr(:,5) = [8.898527e+000 7.274529e+000 3.864522e+000 3.301283e+000 2.725281e+000 2.735561e+000 1.669619e+000 1.856173e+000 1.378671e+000 1.134494e+000 1.079001e+000 8.193450e-001 1.658485e+002 7.463322e-001 7.349408e-001 4.013654e-001 3.767803e-001 2.460454e-001 2.066879e-001 1.467904e-001 1.387437e-001 1.185513e-001 9.134461e-002 8.561751e-002 7.021905e-002 1.649706e+001 1.472147e-001 1.230341e-001 7.962295e-002 5.576596e-002 4.213194e-002 3.501515e-002 2.552259e-002 2.342487e-002 2.173896e-002 1.728433e-002 1.674902e-002 1.349838e-002 2.223754e+000];
cv(:,:,5) = diag(vr(:,5));

mu(:,6) = [-1.245704e+001 1.727279e-001 -2.044427e+000 -3.347555e+000 -5.640296e-001 -1.499485e+000 9.318018e-002 -8.240026e-001 4.853948e-001 -6.545312e-001 2.885908e-001 -3.635652e-001 8.940186e+001 -1.751969e-001 -1.747059e-002 -6.579599e-002 -6.120324e-002 8.652072e-002 -6.479993e-003 8.936679e-005 1.443504e-002 4.219803e-003 2.231600e-003 2.203631e-002 1.013340e-002 4.307183e-001 2.296666e-001 -9.673871e-002 -4.173670e-002 -8.965551e-002 -7.436113e-002 -4.623044e-002 -3.472226e-002 -3.118100e-002 -2.427243e-002 -9.716285e-003 -1.942393e-002 -5.564139e-003 5.645667e-001];
vr(:,6) = [3.188791e+001 8.206201e+000 4.536571e+000 4.255475e+000 2.764527e+000 1.853348e+000 1.402862e+000 1.214313e+000 9.666463e-001 8.940721e-001 7.845169e-001 6.380580e-001 1.713976e+002 4.418462e+000 6.682598e-001 3.245983e-001 4.629432e-001 3.485309e-001 1.991201e-001 1.743232e-001 1.410920e-001 1.139222e-001 9.160137e-002 9.185158e-002 7.063425e-002 1.538414e+001 5.061538e-001 1.195446e-001 6.700704e-002 6.336254e-002 4.179326e-002 3.278161e-002 2.870406e-002 2.408507e-002 2.016679e-002 1.808972e-002 1.666469e-002 1.409546e-002 2.838624e+000];
cv(:,:,6) = diag(vr(:,6));

mu(:,7) = [-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(:,7) = [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(:,:,7) = diag(vr(:,7));

mu(:,8) = [ -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(:,8) = [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(:,:,8) = diag(vr(:,8));
gconst(8) = -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 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 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 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 8.208070e-001 1.791930e-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 9.190401e-001 8.095991e-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 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 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;
    ];

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
