function xcrit = bayes_norm2d (m1,v1,p1, m2,v2, p2)
   minx = min ([min (m1);min (m2)]);
   minx = minx - 2*sqrt(max([max (v1);max(v2)]));
   maxx = max ([max (m1);m (m2)]);
   maxx = maxx + 2*sqrt(max([max (v1);max(v2)]));
   
   x=[minx:0.5:maxx];

   y1=normal_cdf (x, m1, v1);
   y1 = (y1 - shift (y1,1))(2:length (x));

   y2=normal_cdf (x, m2, v2);
   y2 = (y2 - shift (y2,1))(2:length (x));

   pw1=(y1 .* p1) ./ (y1 .* p1 + y2 .* p2);
   pw2=(y2 .* p2) ./ (y1 .* p1 + y2 .* p2);

   xcrit = [x(2:length(x))' pw1' pw2'];
