Consider the
following values for age attribute of total 9 records:
4,8,15,21,21,24,25,28,34
Implement smoothing by bin means
to smooth these data, using a suitable bin depth.code :
import java.util.*;
public class p4
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
int i;
System.out.println("Enter Size of
Data:");
int size = s.nextInt();
int bin[] = new int[size];
System.out.println("Enter
Data:");
for(i=0;i<size;i++)
{
bin[i] = s.nextInt();
}
Arrays.sort(bin);
System.out.println("Sorting
is:"+size);
for(i=0;i<size;i++)
{
System.out.println(""+bin[i]);
}
i=0;
int k=0,j,temp=0,l=0;
System.out.println("Size
is:"+size);
while(i!=((size)/2)-1)
{
for(j=0;j<3;j++)
{
int a = bin[k];
temp = (temp+a);
k++;
}
temp = temp/3;
System.out.println("Mean:
"+temp);
for(j=0;j<3;j++)
{
bin[l] = temp;
l++;
}
temp = 0;
i++;
}
System.out.println("FINAl:
");
for(j=0;j<size;j++)
{
System.out.println("FI:
"+bin[j]);
}
}
}
No comments:
Post a Comment