Commit 06df7bf0 authored by hvernier's avatar hvernier
Browse files

maj ecart type centroid

parent 2b2d5f4a
......@@ -164,8 +164,9 @@ public class AverageDBAMean implements Average<AttributeSequence,ParameterDBAMea
final double[] enveloppeMax = new double[tailleCenter];
for (int t = 0; t < tailleCenter; t++) {
tuplesAverageSeq[t] = moyenne((tupleAssociation[t].toArray()));
enveloppeMin[t] = min((tupleAssociation[t].toArray()));
enveloppeMax[t] = max((tupleAssociation[t].toArray()));
double ecartype = ecartType(tupleAssociation[t].toArray(), tuplesAverageSeq[t]);
enveloppeMin[t] = tuplesAverageSeq[t] - ecartype;//min((tupleAssociation[t].toArray()));
enveloppeMax[t] = tuplesAverageSeq[t] + ecartype;//max((tupleAssociation[t].toArray()));
}
final AttributeSequence newCenter = new AttributeSequence(tuplesAverageSeq);
newCenter.setEnveloppeMax(enveloppeMax);
......@@ -217,5 +218,22 @@ public class AverageDBAMean implements Average<AttributeSequence,ParameterDBAMea
}
return max;
}
public static double ecartType(final double[] tab,final double moyen) {
if (tab.length < 1) {
throw new RuntimeException("tableau de double vide:AttributeSequence.moyenne(Tuple ...tab)");
}
double sum = 0.0;
sum = 0.0;
for (double o : tab) {
sum += abs(o-moyen);
}
return sum / tab.length;
}
public static double abs(final double val) {
return Math.sqrt(val*val);
}
}
......@@ -165,8 +165,11 @@ public class AverageMDDBAMean implements Average<AttributeMultiDimSequence,Param
for (int t = 0; t < tailleCenter; t++) {
moyenneMinMax = moyenneMinMax(tupleAssociation[t].toArray());
tuplesAverageSeq[t] = moyenneMinMax[0];
tuplesAverageSeqMax[t] = moyenneMinMax[1];
tuplesAverageSeqMin[t] = moyenneMinMax[2];
double[] ecartype = ecartType(tupleAssociation[t].toArray(), tuplesAverageSeq[t]);
for(int numTuple = 0; numTuple<oldCenter.getTupleDimension() ; numTuple++) {
tuplesAverageSeqMax[t][numTuple] = tuplesAverageSeq[t][numTuple] - ecartype[numTuple];
tuplesAverageSeqMin[t][numTuple] = tuplesAverageSeq[t][numTuple] + ecartype[numTuple];
}
}
final AttributeMultiDimSequence newCenter = new AttributeMultiDimSequence(tuplesAverageSeq);
newCenter.setEnveloppeMax(tuplesAverageSeqMax);
......@@ -202,5 +205,30 @@ public class AverageMDDBAMean implements Average<AttributeMultiDimSequence,Param
}
public static double[] ecartType(final double[][] tab,final double[] moyen) {
if (tab.length < 1) {
throw new RuntimeException("tableau de double vide:AttributeSequence.moyenne(Tuple ...tab)");
}
double[] sum = new double[tab[0].length];
for (int j = 0; j < tab[0].length; j++) {
sum[j] = 0.0;
}
for (int i = 0; i < tab.length; i++) {
for (int j = 0; j < tab[0].length; j++) {
sum[j] += abs(moyen[j]-tab[i][j]);
}
}
for (int j = 0; j < tab[0].length; j++) {
sum[j] /= tab.length;
}
return sum;
}
public static double abs(final double val) {
return Math.sqrt(val*val);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment