function [ LogL] = Log_likelihood_fun_Sentiment(u,Xt,DataSize)
    
    P12=u(1);
    P21=u(2);
    psi1=u(3);
    psi2=u(4);
    sigma_X=u(5);
    P11=1-P12;
    %P22=1-P21;
    f1=zeros(DataSize,1);
    f2=zeros(DataSize,1);
    pi1=zeros(DataSize+1,1); % pi1(t) stands for \pi(t-\Delta t|t-\Delta t), so pi1(1) stands for \pi(0|0)
    pi2=zeros(DataSize,1); % pi2(t) stands for \pi(t|t-\Delta t)
    pi1(1)=P21/(P12+P21);
    LogL=0; %minus log likehood function
    
    for j=1:DataSize
        f1(j)=1/sqrt(2*pi)/sigma_X*exp(-(Xt(j)-psi1)^2/2/sigma_X^2);
        f2(j)=1/sqrt(2*pi)/sigma_X*exp(-(Xt(j)-psi2)^2/2/sigma_X^2);
        pi2(j)=pi1(j)*P11+(1-pi1(j))*P21;
        pi1(j+1)=f1(j)*pi2(j)/(f1(j)*pi2(j)+f2(j)*(1-pi2(j)));
        LogL=LogL-log(f1(j)*pi1(j+1)+f2(j)*(1-pi1(j+1))); 
    end

end

