diff hackday/DynamicVector.cpp @ 31:9a70d9abdc8b

examining the tempo speed process
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Sun, 11 Dec 2011 17:19:34 +0000
parents 49a5b023df1e
children
line wrap: on
line diff
--- a/hackday/DynamicVector.cpp	Wed Dec 07 13:04:59 2011 +0000
+++ b/hackday/DynamicVector.cpp	Sun Dec 11 17:19:34 2011 +0000
@@ -90,6 +90,26 @@
 
 }
 
+void DynamicVector::updateLimitedIntegratedEstimate(){
+	//returns the index of the integrated average - where the probability distribution is centred
+	//but limited round the MAP estimate
+	double tmp = getMaximum();
+	int limit = min(MAPestimate, length - MAPestimate);
+	int start = max(0, MAPestimate - limit);
+	int end = min(MAPestimate + limit, length-1);
+	
+	integratedEstimate = 0;
+	double integratedTotal = 0;
+	for (int i = start;i <= end;i++){
+		integratedEstimate += array[i]*i;
+		integratedTotal += array[i];
+	}
+	if (integratedTotal > 0){
+		integratedEstimate /= integratedTotal;
+	}
+	
+}
+
 
 void DynamicVector::zero(){
 	for (int i = 0;i < array.size();i++)