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 TwoSampProps.</p>
*/
public
class TwoSampPropsExample
{
public static void
main(String arg[])
{
DataManager dm = new DataManager();
TwoSampProps testclass1 =
new TwoSampProps(0.05, 0,
"less", 36, 150, 30, 100);
double testStatistic = testclass1.testStatistic;
double pValue = testclass1.pValue;
double lowerBound = testclass1.confidenceInterval[0];
double upperBound = testclass1.confidenceInterval[1];
TwoSampProps
testclass2 = new TwoSampProps();
double[] confidenceInterval = testclass2.confidenceInterval(0.05, 36,
150, 30, 100);
testStatistic = testclass2.testStatistic(0, 36, 150, 30, 100);
pValue = testclass2.pValue(0.5, "greater", 36, 150, 30, 100);
Hashtable argument1 = new Hashtable();
argument1.put(NULL_VALUE, 0);
argument1.put(SIDE, "equal");
argument1.put(ALPHA, 0.05);
StatisticalAnalysis testclass3 = new TwoSampProps(argument1, 36, 150,
30, 100).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();
TwoSampProps testclass4 = new TwoSampProps(argument2, null);
argument2.put(ALPHA,
0.05);
confidenceInterval = testclass4.confidenceInterval(argument2, 36, 150,
30, 100);
argument2.put(NULL_VALUE, 0);
testStatistic = testclass4.testStatistic(argument2, 36, 150, 30, 100);
argument2.put(SIDE,
"greater");
pValue = testclass4.pValue(argument2, 36, 150, 30, 100);
}
}
Results:
The
test statistic based on non-null constructor
= -1.054
The
p-value based on non-null constructor
= 0.292
The
confidence interval based on non-null constructor = [-0.173 , 0.053]
{TEST_STATISTIC=-1.054,
PROPORTION_H0=0.264, PVALUE=0.292,
PROPORTION_DIFFERENCE_SE_H0=0.0569,
CONFIDENCE_INTERVAL=[D@e0e
POINT_ESTIMATE=-0.06}
The
test statistic based on null constructor
= -1.054
The
p-value based on null constructor
= 0.854
The
confidence interval based on null constructor = [-0.173
, 0.053]
{TEST_STATISTIC=-1.054,
PROPORTION_H0=0.264, PVALUE=0.854,
PROPORTION_DIFFERENCE_SE_H0=0.0569,
CONFIDENCE_INTERVAL=[D@1bf
POINT_ESTIMATE=-0.06}
See also: