Hi,
I’m working on computing the average pace for a specific run test session, using the same time intervals selected in the activity. The goal is to plot these averages on the fitness page and to reduce the manual effort required to identify intervals.
However, I’ve encountered a discrepancy where the average pace computed from my activity field does not match the selected interval average pace. Conversely, when calculating average power, the results align perfectly.
See below:
Here is the code I’m using for the custom activity field to compute pace:
{
// Check if the activity name is "SRT-RPE"
if (activity.name === "SRT-RPE") {
// Access the relevant data streams
velocitySmooth = streams.get("velocity_smooth").data;
columnValues = streams.get("time").data; // Replace with your actual column name
sumVelocity = 0;
count = 0;
// Loop through the data
for (i = 0; i < velocitySmooth.length; i++) {
if (activity.type === "Run" && columnValues[i] >= 90 && columnValues[i] <= 120) {
if (typeof velocitySmooth[i] === "number" && velocitySmooth[i] > 0) {
sumVelocity += velocitySmooth[i];
count++;
}
}
}
// Calculate mean velocity (meters per second)
meanVelocity = (count > 0) ? sumVelocity / count : 0;
// Log the mean velocity in meters per second for debugging or display purposes
console.log(`Mean velocity: ${meanVelocity.toFixed(2)} meters per second`);
// Assign the mean velocity in meters per second to the field
field.value = meanVelocity;
meanVelocity
} else {
// Handle the case where the activity name is not "SRT-RPE"
field.value = null; // or some other default value
null
}
}
What could explain the discrepancy in the mean pace?
Thanks!

