Z Tests

The Z Test provides a variety of different standardization-based tests. They make it possible to test whether

or not a sample accurately represents the population when the standard deviation of the population is

known from previous tests.

Z Test Preliminary Definitions

> Digits := 20;

[Maple Math]

> Ncd := (a,b,sigma,mu) -> (1/2)*(erf((b-mu)/(sigma*sqrt(2))) - erf((a-mu)/(sigma*sqrt(2))));

[Maple Math]

1-Sample Z Test

The 1-Sample Z Test tests the population mean when the standard deviation is known.

In the following xbar is the sample mean, [Maple Math] is the assumed population mean, [Maple Math] is the

standard deviation of the population, and n is the sample size.

Alternate Hypothesis [Maple Math]

> n := 5; xbar := (11.2 + 10.9 + 12.5 + 11.3 + 11.7)/n; sigma := 3; mu[0] := 11.5;

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

> z := (xbar - mu[0])/(sigma/sqrt(n)); p := 1-Ncd(-z,z,1,0);

[Maple Math]

[Maple Math]

> evalf(z);evalf(p);

[Maple Math]

[Maple Math]

Alternate Hypothesis [Maple Math]

> n := 5; xbar := (11.2 + 10.9 + 12.5 + 11.3 + 11.7)/n; sigma := 3; mu[0] := 11.5;

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

> z := (xbar - mu[0])/(sigma/sqrt(n)); p := Ncd(-10^10,z,1,0);

[Maple Math]

[Maple Math]

> evalf(z);evalf(p);

[Maple Math]

[Maple Math]

Alternate Hypothesis [Maple Math]

> n := 5; xbar := (11.2 + 10.9 + 12.5 + 11.3 + 11.7)/n; sigma := 3; mu[0] := 11.5;

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

> z := (xbar - mu[0])/(sigma/sqrt(n)); p := 1-Ncd(-10^10,z,1,0);

[Maple Math]

[Maple Math]

> evalf(z);evalf(p);

[Maple Math]

[Maple Math]

2-Sample Z Test

The 2-Sample Z Test tests whether the population means of two populations are equal when the standard deviations

of the two populations are known.

In the following [Maple Math] and [Maple Math] are the two sample means,

[Maple Math] and [Maple Math] are the standard deviations of the two populations,

and [Maple Math] and [Maple Math] are the two sample sizes.

Alternate Hypothesis [Maple Math]

> n[1] := 5; xbar[1] := (11.2 + 10.9 + 12.5 + 11.3 + 11.7)/n[1]; sigma[1] := 15.5;

[Maple Math]

[Maple Math]

[Maple Math]

> n[2] := 5; xbar[2] := (0.84 + 0.9 + 0.14 + (-0.75) + (-0.95))/n[2]; sigma[2] := 13.5;

[Maple Math]

[Maple Math]

[Maple Math]

> z := (xbar[1] - xbar[2])/sqrt((sigma[1]^2/n[1]) + (sigma[2]^2/n[2])); p := 1-Ncd(-z,z,1,0);

[Maple Math]

[Maple Math]

> evalf(z);evalf(p);

[Maple Math]

[Maple Math]

Alternate Hypothesis [Maple Math]

> n[1] := 5; xbar[1] := (11.2 + 10.9 + 12.5 + 11.3 + 11.7)/n[1]; sigma[1] := 15.5;

[Maple Math]

[Maple Math]

[Maple Math]

> n[2] := 5; xbar[2] := (0.84 + 0.9 + 0.14 + (-0.75) + (-0.95))/n[2]; sigma[2] := 13.5;

[Maple Math]

[Maple Math]

[Maple Math]

> z := (xbar[1] - xbar[2])/sqrt((sigma[1]^2/n[1]) + (sigma[2]^2/n[2])); p := Ncd(-10^10,z,1,0);

[Maple Math]

[Maple Math]

> evalf(z);evalf(p);

[Maple Math]

[Maple Math]

Alternate Hypothesis [Maple Math]

> n[1] := 5; xbar[1] := (11.2 + 10.9 + 12.5 + 11.3 + 11.7)/n[1]; sigma[1] := 15.5;

[Maple Math]

[Maple Math]

[Maple Math]

> n[2] := 5; xbar[2] := (0.84 + 0.9 + 0.14 + (-0.75) + (-0.95))/n[2]; sigma[2] := 13.5;

[Maple Math]

[Maple Math]

[Maple Math]

> z := (xbar[1] - xbar[2])/sqrt((sigma[1]^2/n[1]) + (sigma[2]^2/n[2])); p := 1 - Ncd(-10^10,z,1,0);

[Maple Math]

[Maple Math]

> evalf(z);evalf(p);

[Maple Math]

[Maple Math]

1-Prop Z Test

The 1-Prop Z Test tests whether data that satisfies certain criteria reaaches a specific proportion

of the population given the sample size and the number of data satisfying the criteria.

In the following x is the number of data satisfying the criteria, [Maple Math] is the assumed population proportion,

and n is the sample size.

Alternate Hypothesis [Maple Math]

> n := 4040; x := 2048; p[0] := 0.5;

[Maple Math]

[Maple Math]

[Maple Math]

> z := (x/n - p[0])/sqrt(p[0]*(1-p[0])/n); p := 1-Ncd(-z,z,1,0);

[Maple Math]

[Maple Math]

> evalf(z);evalf(p);

[Maple Math]

[Maple Math]

Alternate Hypothesis [Maple Math]

> n := 4040; x := 2048; p[0] := 0.5;

[Maple Math]

[Maple Math]

[Maple Math]

> z := (x/n - p[0])/sqrt(p[0]*(1-p[0])/n); p := Ncd(-10^10,z,1,0);

[Maple Math]

[Maple Math]

> evalf(z);evalf(p);

[Maple Math]

[Maple Math]

Alternate Hypothesis [Maple Math]

> n := 4040; x := 2048; p[0] := 0.5;

[Maple Math]

[Maple Math]

[Maple Math]

> z := (x/n - p[0])/sqrt(p[0]*(1-p[0])/n); p := 1-Ncd(-10^10,z,1,0);

[Maple Math]

[Maple Math]

> evalf(z);evalf(p);

[Maple Math]

[Maple Math]

2-Prop Z Test

The 2-Prop Z Test is used to compare the proportions of two samples that satisfy certain criteria.

In the following [Maple Math] and [Maple Math] are the number of data in the two samples that satisfy the criteria,

and [Maple Math] and [Maple Math] are the two sample sizes.

Alternate Hypothesis [Maple Math]

> x[1] := 225; n[1] := 300; x[2] := 230; n[2] := 300;

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

> phat := (x[1]+x[2])/(n[1]+n[2]);
z := abs(x[1]/n[1] - x[2]/n[2])/sqrt(phat*(1-phat)*(1/n[1] + 1/n[2]));
p := 1-Ncd(-z,z,1,0);

[Maple Math]

[Maple Math]

[Maple Math]

> evalf(z);evalf(p);

[Maple Math]

[Maple Math]

Alternate Hypothesis [Maple Math]

> x[1] := 225; n[1] := 300; x[2] := 230; n[2] := 300;

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

> phat := (x[1]+x[2])/(n[1]+n[2]);
z := (x[1]/n[1] - x[2]/n[2])/sqrt(phat*(1-phat)*(1/n[1] + 1/n[2]));
p := Ncd(-10^10,z,1,0);

[Maple Math]

[Maple Math]

[Maple Math]

> evalf(z);evalf(p);

[Maple Math]

[Maple Math]

Alternate Hypothesis [Maple Math]

> x[1] := 225; n[1] := 300; x[2] := 230; n[2] := 300;

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

> phat := (x[1]+x[2])/(n[1]+n[2]);
z := (x[1]/n[1] - x[2]/n[2])/sqrt(phat*(1-phat)*(1/n[1] + 1/n[2]));
p := 1-Ncd(-10^10,z,1,0);

[Maple Math]

[Maple Math]

[Maple Math]

> evalf(z);evalf(p);

[Maple Math]

[Maple Math]