import
static java.lang.System.out;
import java.util.*;
import javastat.*;
import javastat.inference.twosamples.*;
import static javastat.util.Argument.*;
import static javastat.util.Output.*;
import javastat.util.*;
/**
*
*
<p>Example: class TwoSampMeansZTest.</p>
*/
public
class TwoSampMeansZTestExample
{
public static void
main(String arg[])
{
double[] testdata1 = {30, 40, 28, 5, 28, 29, 38, 36, 23, 22, 51, 33, 35,
42, 21, 31, 44, 32, 30, 32, 30, 30, 45, 29, 35,
33, 40, 31, 37, 41, 34, 40, 29, 42, 17, 29, 34,
39};
double[] testdata2 = {60, 68, 63, 37, 57, 52, 63, 68, 47, 44, 74, 71,
83, 92, 66, 64, 62, 73, 62,
51, 77, 77, 71, 53,
72, 58, 70, 58, 72, 81, 64, 60, 60, 72, 40, 61,
58, 69};
DataManager dm = new DataManager();
TwoSampMeansZTest testclass1 =
new TwoSampMeansZTest(0.05,
0, "equal", testdata1, testdata2);
double testStatistic = testclass1.testStatistic;
double pValue = testclass1.pValue;
double lowerBound = testclass1.confidenceInterval[0];
double upperBound = testclass1.confidenceInterval[1];
TwoSampMeansZTest testclass2 = new TwoSampMeansZTest();
double[] confidenceInterval = testclass2.confidenceInterval(0.05,
testdata1, testdata2);
testStatistic = testclass2.testStatistic(0, testdata1, testdata2);
pValue = testclass2.pValue(0, "greater", testdata1,
testdata2);
Hashtable argument1 = new Hashtable();
argument1.put(ALPHA, 0.05);
argument1.put(NULL_VALUE, 0);
argument1.put(SIDE, "equal");
StatisticalAnalysis
testclass3 = new TwoSampMeansZTest(argument1,
testdata1, testdata2).statisticalAnalysis;
testStatistic = (Double) testclass3.output.get(TEST_STATISTIC);
pValue = (Double) testclass3.output.get(PVALUE);
confidenceInterval
= (double[]) testclass3.output.get(
CONFIDENCE_INTERVAL);
lowerBound = confidenceInterval[0];
upperBound = confidenceInterval[1];
Hashtable argument2 = new Hashtable();
TwoSampMeansZTest
testclass4 =
new
TwoSampMeansZTest(argument2, null);
argument2.put(ALPHA, 0.05);
confidenceInterval = testclass4.
confidenceInterval(argument2,
testdata1, testdata2);
argument2.put(NULL_VALUE, 0);
testStatistic = testclass4.testStatistic(argument2, testdata1,
testdata2);
argument2.put(SIDE, "greater");
pValue = testclass4.pValue(argument2, testdata1, testdata2);
}
}
Results:
The
test statistic based on non-null constructor
= -13.402
The
p-value based on non-null constructor
= 0.0
The
confidence interval based on non-null constructor = [-35.745 , -26.624]
{TEST_STATISTIC=-13.402,
PVALUE=0.0, POINT_ESTIMATE_SE=2.327,
POINT_ESTIMATE=-31.184,
CONFIDENCE_INTERVAL=[D@1bf
The
test statistic based on null constructor
= -13.402
The
p-value based on null constructor
= 1.0
The
confidence interval based on null constructor = [-35.745
, -26.624]
{TEST_STATISTIC=-13.402,
PVALUE=1.0,
CONFIDENCE_INTERVAL=[D@
See also: