function Est=EstimateSDE(trajec, dimHmm, previterbi, steps)
javaclasspath({
   '/home/cocktail/meerbach/Netbeans_projects/Metamacs/dist/lib/colt.jar'...
   '/home/cocktail/meerbach/javawerkstatt/Metamacs/lib/concurrent.jar'...
   '/home/cocktail/meerbach/Netbeans_projects/Metamacs/build/classes/'...
   '/home/cocktail/luedge/mbtoolkit/torsten/FRETanalyser/netbeans_project/build/classes'...
   
  });

%%import biocomp.metamacs.hmm.newImplementation.*;
import biocomp.metamacs.hmm.newImplementation.HMMVAR;
%%--------
%trajec(:,2)=0;
size(trajec,1)
precision=1.0000e-04;
if  previterbi==0;
previterbi=randViterbi(dimHmm,size(trajec,1));
Est.preVit=previterbi;
else
end
%% -       Estimate with HMM-SDE    -
hmm=HMMVAR(trajec, dimHmm, 1, []); 
hmm.initializeModel(previterbi)
Est.hmm=hmm;
Est.MLH = hmm.EMcorrect(steps, precision, true);
%Est.MLH = hmm.EM(steps, precision, true);


%% -       final Viterbi-path        -
Est.viterbi=hmm.computeViterbiPath(); 

%% --------------------get-estimated parameter------------
Est.TransitionMatrix=hmm.getTransitionMatrix();
CovM=hmm.getCovariances();
Phi=hmm.getRegressionMatrices;

Est.Phi=Phi;

for i=1:size(Phi,1)
Cov(i)=squeeze(CovM(i,:,:));
S(:,i)=squeeze(Est.Phi(i,:,:));
mu(i)=S(1,i)/(1-S(2,i));
end


Est.Covariances=Cov;
Est.expTauF=S;
%expTauF1=S1(:,2:size(S1,2));
%expTauF2=S2(:,2:size(S2,2));

Est.mu=mu;


