Java Reference
In-Depth Information
double
sum
#
(
double
) sumAvailable();
double
sigma[]
#
new double
[specification.attributes().
size()];
double
sumSigma
#
0.0;
Iterator it_attr
#
specification.
attributes().iterator();
for
(
int
i
#
0; it_attr.hasNext();
!!
i)
{ // for each attribute
AttributeSpec attribute
#
(AttributeSpec)it_attr.next();
sigma[i]
#
0.0;
double
average
#
sum / ((double)attribute.getValues().
size());
double
rank[]
#
new double
[attribute.getValues().
size()];
double
max
#
0;
Iterator it_val
#
attribute.getValues().iterator();
for
(
int
j
#
0;it_val.hasNext();
!!
j){ // for each value
Value value
#
(Value)it_val.next();
int
count
#
sumAvailable(attribute.getName(),value);
rank[j]
#
(
double
)count;
if
(rank[j]>max) max
#
rank[j];
sigma[i]
!#
(count - average)*(count - average);
}
sigma[i] /
#
rank.length;
sumSigma
!#
sigma[i];
// the rank is proportional to how close the value
// is to the value with the highest availability
// i.e. preference is given to most available values
Value values[]
#
new
Value[rank.length];
attribute.getValues().toArray(values);
for
(
int
j
#
0; j<rank.length;
!!
j){
for
(
int
k
#
0; k<rank.length-1; k
!!
){
if
(rank[k]<rank[k
!
1]){
double temp
#
rank[k];
rank[k]
#
rank[k
!
1];
rank[k
!
1]
#
temp;
Value tempVal
#
values[k];
values[k]
#
values[k
!
1];
values[k
!
1]
#
tempVal;
}
}
}
double
step
#
1.0/rank.length;
double
rankValue
#
1.0;
for
(
int
j
#
0; j<rank.length;
!!
j,rankValue-
#
step){