function [Qdupl,Odupl] = func_duplicateState(Q,O,ind)
% Duplicate state i of the transition matrix Q.
% More precisely:
%  - all incoming flow will be distributed equally between the copies;
%  - the outgoing flow of the copies (towards all states but itself and the other copy) is equal to the one of the original;
%  - the probability to stay in one copy is equal to half of the probability to stay in the original state.

k = size(Q,1);
m = size(O,1);
tau = [1:k ind];
Qdupl = Q(tau, tau);
tempMatr = eye(k+1);
tempMatr(ind,ind) = 1/2;
tempMatr(k+1,k+1) = 1/2;
Qdupl = Qdupl * tempMatr;

Odupl = O(1:m, tau);
