sources
Class CategorialVariable

java.lang.Object
  extended bysources.Variable
      extended bysources.CategorialVariable
Direct Known Subclasses:
DerivedCategorialVariable

public class CategorialVariable
extends Variable

A class that represents a categorial variable


Field Summary
 
Fields inherited from class sources.Variable
id, name
 
Constructor Summary
CategorialVariable(int[] ordvalues, int length, java.lang.String nam, int identnr)
          create a new categorial variable from an integer array
CategorialVariable(java.lang.String[] names, int length, java.lang.String nam, int identnr)
          Creates new CategorialVariable
CategorialVariable(java.lang.String[] names, int length, java.lang.String nam, int identnr, int ident)
          Creates new CategorialVariable same as above (without calculations)
 
Method Summary
 int[] getCasesFromCat(int cat, int[] cases)
          returns an array of cases, given a specific category number and an array of initial cases Used for mosaic plots!
 int getCatNumberFromName(java.lang.String str)
          returns the category number of a category name
 int getCatsAnz()
          Returns the number of categories
 int getCatsValueFrom(int c)
          returns the category number of one case
 int getCount()
          returns the number of cases
 double[] getCountsforCats()
          returns an array of the counts for every category of this variable
 double[] getCountsforCats(ContinuousVariable var)
          returns an array of weights for every category of this variable
 double[] getCountsforCats(ContinuousVariable var, Selectioner sel)
          returns an array of selected weights for all categories of this variable
 double[] getCountsforCats(Selectioner sel)
          returns an array of selected counts for all categories of this variable
 java.lang.String getNamefromCat(int i)
          return the name from the category of i
 boolean[] getPositionsfrom(int d)
          Return all cases with selected category
 boolean[] getPositionsfrom(java.lang.String c)
          Return all cases with selected category
 java.lang.String getTextualRepresentation(int i)
          Returns the textual Representation of this case
 java.lang.String[] getValues()
          Return values of the variable
 void prepare()
          prepares this variable
 
Methods inherited from class sources.Variable
equals, getID, getName, getTextualRepresentations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CategorialVariable

public CategorialVariable(java.lang.String[] names,
                          int length,
                          java.lang.String nam,
                          int identnr)
Creates new CategorialVariable

Parameters:
identnr - the identity number of this variable
names - category per case
length - # cases
nam - Name of the Variable

CategorialVariable

public CategorialVariable(java.lang.String[] names,
                          int length,
                          java.lang.String nam,
                          int identnr,
                          int ident)
Creates new CategorialVariable same as above (without calculations)

Parameters:
names -
length -
nam -
identnr -
ident -

CategorialVariable

public CategorialVariable(int[] ordvalues,
                          int length,
                          java.lang.String nam,
                          int identnr)
create a new categorial variable from an integer array

Parameters:
ordvalues - the integer array
length - the length of the array
nam - the name of this variable
identnr - the identity number of the variable
Method Detail

prepare

public void prepare()
prepares this variable


getCount

public int getCount()
returns the number of cases

Specified by:
getCount in class Variable
Returns:
number of cases

getCatsAnz

public int getCatsAnz()
Returns the number of categories

Returns:
number of categories

getNamefromCat

public java.lang.String getNamefromCat(int i)
return the name from the category of i

Parameters:
i - the category
Returns:
the name of this category

getCatsValueFrom

public int getCatsValueFrom(int c)
returns the category number of one case

Parameters:
c - the position of the desired case
Returns:
the category number of this case

getTextualRepresentation

public java.lang.String getTextualRepresentation(int i)
Returns the textual Representation of this case

Specified by:
getTextualRepresentation in class Variable
Parameters:
i - case to get the textual representation
Returns:
textual representation

getValues

public java.lang.String[] getValues()
Return values of the variable

Returns:
values of the variable

getPositionsfrom

public boolean[] getPositionsfrom(java.lang.String c)
Return all cases with selected category

Parameters:
c - Category as String
Returns:
true, if case[i] is of that category

getCatNumberFromName

public int getCatNumberFromName(java.lang.String str)
returns the category number of a category name

Parameters:
str - the name of the category
Returns:
the int number of this category

getPositionsfrom

public boolean[] getPositionsfrom(int d)
Return all cases with selected category

Parameters:
d - Category in int
Returns:
true, if case[i] is of that category

getCountsforCats

public double[] getCountsforCats()
returns an array of the counts for every category of this variable

Returns:
the count array of the variables

getCountsforCats

public double[] getCountsforCats(ContinuousVariable var)
returns an array of weights for every category of this variable

Parameters:
var - the weight variable
Returns:
the weight array

getCountsforCats

public double[] getCountsforCats(Selectioner sel)
returns an array of selected counts for all categories of this variable

Parameters:
sel - the selectioner, including the selected values
Returns:
the count array

getCountsforCats

public double[] getCountsforCats(ContinuousVariable var,
                                 Selectioner sel)
returns an array of selected weights for all categories of this variable

Parameters:
var - the weight variable
sel - the selectioner
Returns:
the weight array

getCasesFromCat

public int[] getCasesFromCat(int cat,
                             int[] cases)
returns an array of cases, given a specific category number and an array of initial cases Used for mosaic plots!

Parameters:
cat - the category number
cases - the initial cases
Returns:
the subset of cases from "cases" being of category number