1.04.26 #6
63
src/ecoparasite/completion/Completion.java
Normal file
63
src/ecoparasite/completion/Completion.java
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
package ecoparasite.completion;
|
||||||
|
|
||||||
|
import ecoparasite.poisson.Poisson;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
public class Completion {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param tablePoisson
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public HashSet<Poisson> completePoisson(HashSet<Poisson> tablePoisson){
|
||||||
|
|
||||||
|
double mean = mean(tablePoisson); //Moyenne
|
||||||
|
double ecart = ecartType(tablePoisson); // Ecart Type
|
||||||
|
|
||||||
|
double z = 0;
|
||||||
|
|
||||||
|
for (Poisson p : tablePoisson) {
|
||||||
|
z = ( p.getInfestation() - mean ) / ecart;
|
||||||
|
|
||||||
|
if ( z >= 3 ) {
|
||||||
|
p.setInfestation(mean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tablePoisson;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double mean(HashSet<Poisson> tablePoisson){
|
||||||
|
|
||||||
|
double mean = 0.0;
|
||||||
|
|
||||||
|
for (Poisson p : tablePoisson){
|
||||||
|
mean += p.getInfestation();
|
||||||
|
}
|
||||||
|
|
||||||
|
return mean / tablePoisson.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
private double variance(HashSet<Poisson> tablePoisson){
|
||||||
|
|
||||||
|
double vari = 0.0;
|
||||||
|
double mean = mean(tablePoisson);
|
||||||
|
|
||||||
|
for (Poisson p : tablePoisson) {
|
||||||
|
vari += Math.pow( (p.getInfestation() - mean), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return vari / tablePoisson.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
private double ecartType(HashSet<Poisson> tablePoisson){
|
||||||
|
|
||||||
|
double vari = variance(tablePoisson);
|
||||||
|
|
||||||
|
return Math.sqrt(vari);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -61,6 +61,14 @@ public class Poisson{
|
|||||||
return infestation;
|
return infestation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter de l'attribut infestation
|
||||||
|
* @param infestation le Double de la nouvelle valeur de l'infestation
|
||||||
|
*/
|
||||||
|
public void setInfestation(Double infestation) {
|
||||||
|
this.infestation = infestation;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permet d'afficher les informations de notre poisson
|
* Permet d'afficher les informations de notre poisson
|
||||||
* @return La string contenant les informations
|
* @return La string contenant les informations
|
||||||
|
|||||||
Reference in New Issue
Block a user