Here's the deal: two ways to calculate work done are to either integrate power with respect to time (which I did) or to integrate force with respect to distance.
So what I did: first I considered the effect of bike speed fluctuations on average power. Bike speed varies over time with a particular average value, this yields fluctuations in power as a function of time, and these fluctuations in power average to a larger value than the power which would result from a constant speed equal to the average speed. But if average speed over time is the same, then distance covered is the same, which is the desired constraint of the calculation.
Then I considered the effect of grade fluctuations on speed. But the speed must average the same over time, while grade was analyzed over distance.
All good if the speed is constant, in which case distance and time are proportional. But it's not. If the grade is 7%, for example, then at constant power in the absence of other variable effects I maintain the same speed. However, if the grade is 10% half the time and 4% half the time, the same average grade, I'll spend more time on the 10% than I do on the 4%. It gets hard to wrap your head around. It seems like average power should increase: I'm spending more than half the time at increased power, less than half the time at decreased power, a net average change greater than zero.
But there's that other approach to extracting work: force integrated over distance. Change in force is proportional to change in grade. So if the grade is higher for half the distance, lower by the same amount for the other half, the force averaged over distance in the absence of wind resistance is the same. Thus for f = 0 the result needs to be zero, as I derived. The key is that total time, and therefore average speed, is fixed.
The only thing left is whether the variation in grade therefore needs to be calculated differently than simply deriving statistics from a profile with respect to distance. For example, one could calculate a weighted distribution, with weighting proportional to the inverse of the speed associated with a given grade. Well, maybe or maybe not. These things tend to be tricky, and if you forget the final constraint of fixed average speed, you get the wrong answer. But my suspicion is you want to calculate the fluctuations with respect to time.
Fortuitously, in my last result I used iBike data, which provides grade as a function of time, so all was good. More typically I don't have iBike data, and so have grade over distance instead. Of course for a given hill grade over time will vary depending on who rides it, while grade over distance in the absence of seismic activity is the same.
So would it make a difference? Well, easily checked for this particular data set. I took the data I used from that analysis and calculated the standard deviation of grade, as before. Then I interpolated the data onto a uniform mesh of 6000 points equally spaced in distance, and took the standard deviation again. Here's the results:
- over time: σ = 2.03622%
- over distance: σ = 2.03626%