function ny=gausshist(mu,sd,n,xx)
width=(xx(end)-xx(1))/(length(xx)-1);
ny=n/2*(erf((1/sqrt(2)/sd)*(xx-mu+(width/2))))-n/2*(erf((1/sqrt(2)/sd)*(xx-mu-(width/2))));
postail=n/2*(erf((1/sqrt(2)/sd)*(Inf)))-n/2*(erf((1/sqrt(2)/sd)*(xx(end)-mu+(width/2))));
negtail=n/2*(erf((1/sqrt(2)/sd)*(xx(1)-mu-(width/2))))-n/2*(erf((1/sqrt(2)/sd)*(-Inf)));
total=sum(ny)+postail+negtail
%start of addition 9/22/99 by bfw
ny(1)=ny(1)+negtail;
ny(end)=ny(end)+postail;
%end of addition 9/22/99 by bfw
