hi,
i'm coding to take a input vector inputdata, and continuously find standard deviation to count how many distinct data ar available.for this i implement a small method called findk().

public  int findk(Vector inputdata  ,double minSD)
         {

            inputdata=new Vector();
             double tolerance=0.001,thisSD;
             Collections.sort(inputdata);
             
             if(minSD<0.0)
             this.minSD =inputdata.getStandardDeviation();
             inputdata d1= getHalf(1,inputdata);
             inputdata d2 = getHalf(2,inputdata);
             thisSD=d1.getStandardDeviation();
             
             if(thisSD+tolerance < minSD)
             return 1 + findk(d1,thisSD);
             thisSD=d2.getStandardDeviation();
             if(thisSD+tolerance < minSD)
               return 1 + findk(d2,thisSD);
               return 0;
          }

but the code shows the following error
[output]

C:\Program Files\Java\jdk1.6.0_03\bin>javac ClusterAnalysis.java
ClusterAnalysis.java:336: cannot find symbol
symbol : method getStandardDeviation()
location: class java.util.Vector
this.minSD =inputdata.getStandardDeviation();
^
ClusterAnalysis.java:337: cannot find symbol
symbol : class inputdata
location: class ClusterAnalysis
inputdata d1= getHalf(1,inputdata);
^
ClusterAnalysis.java:337: cannot find symbol
symbol : method getHalf(int,java.util.Vector)
location: class ClusterAnalysis
inputdata d1= getHalf(1,inputdata);
^
ClusterAnalysis.java:338: cannot find symbol
symbol : class inputdata
location: class ClusterAnalysis
inputdata d2 = getHalf(2,inputdata);
^
ClusterAnalysis.java:338: cannot find symbol
symbol : method getHalf(int,java.util.Vector)
location: class ClusterAnalysis
inputdata d2 = getHalf(2,inputdata);
^
ClusterAnalysis.java:342: operator + cannot be applied to int,<any>
return 1 + findk(d1,thisSD);
^
ClusterAnalysis.java:342: incompatible types
found : <nulltype>
required: int
return 1 + findk(d1,thisSD);
^
ClusterAnalysis.java:345: operator + cannot be applied to int,<any>
return 1 + findk(d2,thisSD);
^
ClusterAnalysis.java:345: incompatible types
found : <nulltype>
required: int
return 1 + findk(d2,thisSD);
^
Note: ClusterAnalysis.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
9 errors

[/output]

Plz help me to solve this problem. Thanks in advance.

Check out the docs for java.util.Vector, where do you find the method getStandardDeviation() in it ? Also all the other errors are pretty straight forward, the compiler gives a reason for the error, the line number where the error occurs in your program and the shows the line too, you should be able to sort them out on your own, we would not explain the reason for and provide the solution for each and every error.

Also, getting standard deviation is a multi-step process, is it not? Do you think it would be worthwhile to make different methods to do the separate parts? For example, standard deviation includes finding the mean, and I would think a method that finds the mean would be reusable and logically, would be a separate part of computing the standard deviation. Just a thought. (As a side note, I don't know how much it applies to a small example like this, but separating code into logical chunks also makes error checking easier)

Also, check out how to create objects in Java - a Vector might be created by

Vector animals = new Vector();

You have to specify the type.

This article has been dead for over six months. Start a new discussion instead.