Guest User

Untitled

a guest
Jun 18th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. import graph;
  2. import patterns;
  3.  
  4. size(300,200,IgnoreAspect);
  5.  
  6. real xmin=-4,xmax=4;
  7. real ymin=0,ymax=1;
  8. real PI=3.141593;
  9. real sd=.6;
  10. real a=1, b=-.5;
  11.  
  12. // Definition of fonctions f and g :
  13. real f(real x) {return 1/sqrt(2*PI*sd)*exp(-(x+.5)^2/(2*sd));}
  14. real g(real x) {return 1/sqrt(2*PI*sd)*exp(-(x-1)^2/(2*sd));}
  15.  
  16. // Trace the curves :
  17. path Cf=graph(f,xmin,xmax,n=400);
  18. path Cg=graph(g,xmin,xmax,n=400);
  19. draw(Cf,linewidth(1bp));
  20. draw(Cg,linewidth(1bp));
  21. xlimits(xmin,xmax,Crop);
  22. ylimits(ymin,ymax,Crop);
  23.  
  24. draw((a,0)--(a,g(a)),dashed);
  25. draw((b,0)--(b,f(b)),dashed);
  26. draw((0.4,0)--(0.4,f(0.4)),linewidth(2bp));
  27.  
  28. label("\small $H_1$",(a,.6));
  29. label("\small $(\mu_0+\delta;\sigma^2)$",(a,.55));
  30. label("\small $H_0$",(b,.6));
  31. label("\small $(\mu_0;\sigma^2)$",(b,.55));
  32. arrow(minipage("\centering\footnotesize $\Pr(-\mid H_0\, \textrm{true})$\\ \bf Correct decision (TN)"),(-1.05,.35),NW);
  33. arrow(minipage("\centering\footnotesize $\Pr(+\mid H_0\, \textrm{true})$\\ \bf Type I error risk ($\alpha$)"),(0.75,.1),NE);
  34.  
  35. //xaxis("Internal Response (a.u.)",Bottom);
  36. //yaxis("Probability",Left);
  37.  
  38. path q0=(0.4,0)--(0.25,1);
  39. path q1=(xmin,0)--(xmin,1);
  40. path q2=(xmin,0)--(xmax,0);
  41. path q3=(xmax,0)--(xmax,1);
  42. add("hachure",hatch(8,NW));
  43. add("hachure2",hatch(4,NE));
  44.  
  45. fill(buildcycle(q1,graph(f,xmin,xmax),q0,q2),pattern("hachure"));
  46. fill(buildcycle(q0,graph(f,xmin,xmax),q3,q2),pattern("hachure2"));
Add Comment
Please, Sign In to add comment