function ny=gausscomp(mu,sd,n,xx)
%note scale change below to allow different treatment of tails.
width=(xx(end)-xx(1))/(length(xx)-1);
ny=1/2*(erf((1/sqrt(2)/sd)*(xx-mu+(width/2))))-1/2*(erf((1/sqrt(2)/sd)*(xx-mu-(width/2))));
postail=1/2*(erf((1/sqrt(2)/sd)*(Inf)))-1/2*(erf((1/sqrt(2)/sd)*(xx(end)-mu+(width/2))));
negtail=1/2*(erf((1/sqrt(2)/sd)*(xx(1)-mu-(width/2))))-1/2*(erf((1/sqrt(2)/sd)*(-Inf)));
total=sum(ny)+postail+negtail;
%start of addition 9/25/99 by bfw
subtotal=sum(ny(2:end-1));
ny(1)=ny(1)+negtail;
ny(end)=ny(end)+postail;
ny=n*ny*total/subtotal;
%end of addition 9/25/99 by bfw
