Here’s one that calculates Running Efficiency per Interval
if ((activity.type == “Run” || activity.type == “VirtualRun”) && !activity.icu_ignore_hr)
{
gaStr = streams.get(“ga_velocity”).data
xgap = 0
gaSmooth = 0
smoothBy = 30 //seconds
count = interval.end_index - interval.start_index
for (let i=0; i<count; i++)
{
gaSmooth = gaSmooth + gaStr[interval.start_index + i]
if(i%smoothBy == 0 || i+1 == count)
{
xgap = xgap + ((gaSmooth/smoothBy ) ** 4)
gaSmooth = 0
}
}
//calculates normalized average
xgap = (xgap / Math.ceil(count/smoothBy))**(1/4)
eff = (xgap * 60) / (activity.average_heartrate)
eff = +eff.toFixed(2)
}