function flucTraj=fluctuator(Viterbipath, flucVersion, params)
%% set $flucVersion to 0 for gaussian noise, 1 for random walk adn 2 for
%% stochastic differential equations
%%

dur=length(Viterbipath);
if flucVersion==0
    for i=1:dur
    flucTraj(i,1)=Viterbipath(i)+params(Viterbipath(i))*randn;
    end
    
elseif=flucVersion==1
    flucTraj(i,1)=Viterbipath(1)
    for i=2:dur
       flucTraj(i,1)=flucTraj(i-1,1)+params(Viterbipath(i))*rand
    end
    
elseif=flucVersion==2
      flucTraj(i,1)=Viterbipath(1)
    for i=2:dur
       flucTraj(i,1)=flucTraj(i-1,1)+flucTraj(i-1,1)*params(Viterbipath(i))*rand
    end
else
    error('usage: "flucTraj=fluctuator(Viterbipath, flucVersion, params)", see mfile for versions')
end
    