protected override int CalculateValue() // convert return type to float????? { var firstVal = YVarValues.First(); var lastVal = YVarValues.Last(); var difference = lastVal - firstVal; // use the MAXIMUM of the captured x variable samples instead of MEAN var denominator = XVar == null ? XCount : (XVarValues.Max() - XVarValues.Min()); // return value double tempResult = (difference * 100) / denominator; var result = Convert.ToInt32(tempResult); //MessageBox.Show("Last Val: " + lastVal + "\nFirst Val: " + firstVal + "\nNumerator: " + difference + "\nDenominator: " + denominator); //MessageBox.Show("Result: " + result); return(result); }
protected override int CalculateValue() // convert return type to float????? { // The Trapezoid Rule (improve to Simpson's rule at some point when updating). var firstYVal = YVarValues.First(); var lastYVal = YVarValues.Last(); int firstXVal; int lastXVal; if (XVar == null) { firstXVal = 0; lastXVal = NoOfSamples; } else { firstXVal = XVarValues.First(); lastXVal = XVarValues.Last(); } var result = (lastXVal - firstXVal) * ((firstYVal + lastYVal) / 2); //MessageBox.Show("First X Val: " + firstXVal + "\nLast X Val: " + lastXVal); //MessageBox.Show("Result: " + result); return(result); }