58 lines
1.3 KiB
Java
58 lines
1.3 KiB
Java
package bpmEstimation;
|
|
|
|
import utilities.Utils;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
/**
|
|
* Created by toni on 03/08/18.
|
|
*/
|
|
public class BpmHistory extends LinkedList<Double> {
|
|
|
|
private double mMean = 0.0;
|
|
private double mVar = 0.0;
|
|
private double mStdDev = 0.0;
|
|
|
|
public boolean add(double val){
|
|
if(val != -1){
|
|
super.add(val);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public boolean add(BpmHistory vals){
|
|
if(!vals.isEmpty()){
|
|
for(double val : vals){
|
|
super.add(val);
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public double getMean(){
|
|
if(this.size() > 2){
|
|
return Utils.mean(this);
|
|
} else {
|
|
return this.getFirst(); //TODO: das ist natürlich quatsch und faulheit. mal schaun wie man das am besten löst.
|
|
}
|
|
}
|
|
|
|
public double getVariance(){
|
|
if(this.size() > 2){
|
|
return Utils.var(this);
|
|
} else {
|
|
return 0; //TODO: das ist natürlich quatsch und faulheit. mal schaun wie man das am besten löst.
|
|
}
|
|
}
|
|
|
|
public double getStd(){
|
|
return Utils.stdDev(this);
|
|
}
|
|
|
|
public void removeOutliers(){
|
|
Utils.removeOutliersZScore(this, 3.4);
|
|
}
|
|
}
|