import java.io.*;
class Main
{
public
static void main(String args[])
{
try
{
BufferedReader
br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter
total numbers : ");
int n = Integer.parseInt(br.readLine());
double a[] = new double[n];
System.out.println("Enter
numbers : ");
for (int i = 0; i < n; i++)
{
a[i]
= Double.parseDouble(br.readLine());
}
double X,E;
System.out.println("Enter
critcal value : ");
X =
Double.parseDouble(br.readLine());
System.out.println("Enter
expected value : ");
E
= Double.parseDouble(br.readLine());
ChiSquareTest
cs=new ChiSquareTest();
cs.chisqr(a,X,E);
}
catch(Exception e)
{
}
}
}
class ChiSquareTest
{
public void
chisqr(double a[],double X,double E)
{
double b[]=new double[a.length];
double sum=0.0;
for(int i=0;i<a.length;i++)
{
b[i]=a[i]-E;
b[i]=b[i]*b[i];
b[i]=(b[i]/E)+(b[i]%E);
sum+=b[i];
}
if(X>sum)
{
System.out.println("Hypothesis
accepted");
}
else
{
System.out.println("Hypothesis
rejected");
}
}
}
No comments:
Post a Comment