clear all; Niter = 10^4; % number of initial x0 Nt=1; % number of times to do the map X0 = zeros(1,Nt); X = zeros(1,Nt); for ia=1:Niter m = 2/3; s = 1/80; x0 = m + s*randn(1); % choose a x0 from a gaussian distributions % with mean m and variance s x0 = mod(x0,1); % if x is outside [0,1] then put it inside by adding integers (see help mod) X0(ia)=x0;% initial x x=x0; for it=1:Nt; if x<1/2 xnew = 2*x; else xnew = 2*(1-x); end x=xnew; end X(ia) = x; % x after Nt steps end; [P0,x0] = hist(X0,20); dx0 = x0(2)-x0(1); P0norm = P0/(Niter*dx0); [P,x] = hist(X,20); dx=x(2)-x(1); Pnorm = P/(Niter*dx); %% figure(3);clf; plot(x0,P0norm,'g',x,Pnorm,'b','LineWidth',2); hold on; plot([0 1],[1 1],'--k') hold off; xlabel('x','FontSize',18); ylabel('p(x)','FontSize',18); pause(1)