function M=survivemovie
% generates a movie for demonstrating the survivorship bias. 
%mean runs from 2 down to 0 while the sd runs form 1 to 10.
nframes=140;
m=3;  sd=1;
x=-8:.05:10;
z=x(x>0);
y=normpdf(x,m,1);
fill(x,y,'g')
hold on
fill(x,min(y,normpdf(-x,m,sd)),'r')
mu=cmean(z,normpdf(z,m,sd)-normpdf(-z,m,sd));
for k = 1:nframes
    m=m-.0125;
    sd=sd*1.01;
    y=normpdf(x,m,sd);
fill(x,y,'g')
hold on
plot(x,min(y,normpdf(-x,m,sd)),'r')
fill(x,min(y,normpdf(-x,m,sd)),'r')
mu=cmean(z,normpdf(z,m,sd)-normpdf(-z,m,sd));
plot(mu*ones(1,5),(0:.1:.4),'b')
hold off
M(k)=getframe;
end
%movie(M,-1,5)    % runs the movie thru once at three frames per second