2026-04-01 14:34:26 +02:00
|
|
|
package ecoparasite.completion;
|
|
|
|
|
|
|
|
|
|
import ecoparasite.poisson.Poisson;
|
|
|
|
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
|
2026-04-01 16:20:41 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class incluant des méthodes Statiques de Completion des données
|
|
|
|
|
*/
|
2026-04-01 14:34:26 +02:00
|
|
|
public class Completion {
|
|
|
|
|
|
|
|
|
|
|
2026-04-01 16:20:41 +02:00
|
|
|
public static HashSet<Poisson> completePoissonMean(HashSet<Poisson> tablePoisson){
|
2026-04-01 14:34:26 +02:00
|
|
|
|
2026-04-01 16:20:41 +02:00
|
|
|
Double mean = mean(tablePoisson);
|
2026-04-01 14:34:26 +02:00
|
|
|
|
2026-04-01 16:20:41 +02:00
|
|
|
for (Poisson p : tablePoisson) {
|
|
|
|
|
if ( p.getInfestation() == null ) {
|
2026-04-01 14:34:26 +02:00
|
|
|
p.setInfestation(mean);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tablePoisson;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 16:20:41 +02:00
|
|
|
private static Double mean(HashSet<Poisson> tablePoisson){
|
2026-04-01 14:34:26 +02:00
|
|
|
|
2026-04-01 16:20:41 +02:00
|
|
|
Double mean = 0.0;
|
2026-04-01 14:34:26 +02:00
|
|
|
|
|
|
|
|
for (Poisson p : tablePoisson){
|
2026-04-01 16:20:41 +02:00
|
|
|
if (p.getInfestation() != null) {
|
|
|
|
|
mean += p.getInfestation();
|
|
|
|
|
}
|
2026-04-01 14:34:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return mean / tablePoisson.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|