void page6() { background(255); generateGraph(); image(pg, 100, 50); String t = "Step 5 - The P-value (continued)"; textFont(myboldfont, 18); text(t, 30, 44); textFont(myfont, 18); if ((aStudy.known == 1) || (aStudy.samplesize>30)) { t = "N(0,1)"; text(t, 330, 85); } else { t = "t" + nf(aStudy.samplesize-1, 1); if (aStudy.samplesize == 10) { text(t, 345, 85); } else { text(t, 340, 85); } } if ((aStudy.known == 1) || (aStudy.samplesize>30)) { if (aStudy.k==0) { t = "Since the alternative is right-tailed, the p-value (indicated in red) equals the total probability, which is 1, minus the left-tailed value."; drawStrings(t, 80, 300, 25); p = 1.0-zvalue; t = "p-value = 1 - " + nf(zvalue, 1, 4) + " = " + nf(p, 1, 4); text(t, 80, 374); } else if (aStudy.k ==1) { t = "Since the alternative is left-tailed, the p-value (indicated in red) just equals the left-tailed value."; drawStrings(t, 80, 300, 25); p = zvalue; t = "p-value = " + nf(p, 1, 4); text(t, 80, 374); } else { t= "Since the alternative is two-tailed, the p-value equals 2 times the minimum of the left-tailed and right-tailed values. " + "The left tailed value equals " + nf(zvalue, 1, 4) + " and the right-tailed value equals one minus the left tailed value which gives us: 1 - " + nf(zvalue, 1, 4) + " = " + nf(1-zvalue, 1, 4)+"."; if (zvalue<0.5) { p = 2.0*zvalue; t+=" The minimum of these two values is " + nf(zvalue, 1, 4) + ", and the p-value is twice the minimum: 2 * " + nf(zvalue, 1, 4) + " = " + nf(2*zvalue, 1, 4)+"."; } else { p = (1.0-zvalue)*2.0; t+=" The minimum of these two values is " + nf(1-zvalue, 1, 4) + ", and the p-value is twice the minimum: 2 * " + nf(1-zvalue, 1, 4) + " = " + nf(2*(1-zvalue), 1, 4)+"."; } drawStrings(t, 80, 270, 25); } } else { if (aStudy.k == 0) { p = 1.0-zvalue; if (testvalue > tcomp) { t = "Since t* > " + nf(tcomp, 1, 4) + ", there must be less than 5% of the area to the right of t*, which means the p-value < 0.05."; } else { t = "Since t* < " + nf(tcomp, 1, 4) + ", there must be more than 5% of the area to the right of t*, which means the p-value > 0.05."; } } else if (aStudy.k == 1) { p = zvalue; if (testvalue < -tcomp) { t = "Since t* < -" + nf(tcomp, 1, 4) + ", there must be less than 5% of the area to the left of t*, which means the p-value < 0.05."; } else { t = "Since t* > -" + nf(tcomp, 1, 4) + ", there must be more than 5% of the area to the left of t*, which means the p-value > 0.05."; } } else { if (zvalue<0.5) { p = 2.0*zvalue; } else { p = (1.0-zvalue)*2.0; } if (abs(testvalue) > tcomp) { t = "Since |t*| > " + nf(tcomp, 1, 4) + ", there must be less than 5% of the area when shading both tails, which means the p-value < 0.05."; } else { t = "Since |t*| < " + nf(tcomp, 1, 4) + ", there must be more than 5% of the area when shading both tails, which means the p-value > 0.05."; } } drawStrings(t, 80, 300, 25); t = "Note: From calculation, the exact p-value = " + nf(p, 1, 4) + " and is indicated in red in the graph above."; drawStrings(t, 80, 380, 25); } }