技术参考和公式

完整的数学实现

实现指南

本页面为所有Run Analytics指标提供即插即用的公式和分步计算方法。使用它们进行自定义实现、验证或更深入的理解。

⚠️ 实现说明

  • 所有时间应转换为秒进行计算
  • 跑步配速是反比关系(更高% = 更慢配速)
  • 始终验证输入在合理范围内
  • 处理边界情况(除以零、负值)

核心性能指标

临界跑步速度 (CRS)

公式:

CRS (m/s) = (D₂ - D₁) / (T₂ - T₁)
CRS Pace/100m (秒) = (T₄₀₀ - T₂₀₀) / 2

🧪 交互式计算器 - 测试公式

每 100m 的 CRS 配速:
1:49
计算步骤:
CRS (m/s) = (400 - 200) / (368 - 150) = 0.917 m/s
Pace/100m = 100 / 0.917 = 109 秒 = 1:49

JavaScript Implementation:

function calculateCRS(distance1, time1, distance2, time2) {
  // Convert times to 秒 if needed
  const t1 = typeof time1 === 'string' ? timeToSeconds(time1) : time1;
  const t2 = typeof time2 === 'string' ? timeToSeconds(time2) : time2;

  // Calculate CRS in m/s
  const css_ms = (distance2 - distance1) / (t2 - t1);

  // Calculate 配速 per 100m in 秒
  const 配速_per_100m = 100 / css_ms;

  // Convert to mm:ss format
  const 分钟 = Math.floor(配速_per_100m / 60);
  const 秒 = Math.round(配速_per_100m % 60);

  return {
    css_ms: css_ms,
    配速_秒: 配速_per_100m,
    配速_formatted: `${分钟}:${秒.toString().padStart(2, '0')}`
  };
}

// Example usage:
const result = calculateCRS(200, 150, 400, 368);
// Returns: { css_ms: 0.917, 配速_秒: 109, 配速_formatted: "1:49" }

Run 训练压力评分 (sTSS)

Complete Formula:

sTSS = (IF³) × Duration (小时) × 100
IF = NSS / FTP
NSS = Total Distance / Total Time (m/min)

🧪 交互式计算器 - 测试公式

计算的 sTSS:
55
计算步骤:
NSS = 3000m / 55min = 54.5 m/min
FTP = 100 / (93/60) = 64.5 m/min
IF = 54.5 / 64.5 = 0.845
sTSS = 0.845³ × (55/60) × 100 = 55

JavaScript Implementation:

function calculateSTSS(distance, timeMinutes, ftpMetersPerMin) {
  // Calculate Normalized Run Speed
  const nss = distance / timeMinutes;

  // Calculate Intensity Factor
  const intensityFactor = nss / ftpMetersPerMin;

  // Calculate 小时
  const 小时 = timeMinutes / 60;

  // Calculate sTSS using cubed intensity factor
  const stss = Math.pow(intensityFactor, 3) * 小时 * 100;

  return Math.round(stss);
}

// Example usage:
const stss = calculateSTSS(3000, 55, 64.5);
// Returns: 55

// Helper: Convert CRS to FTP
function cssToFTP(cssPacePer100mSeconds) {
  // FTP in m/min = 100m / (配速 in 分钟)
  return 100 / (cssPacePer100mSeconds / 60);
}

// Example: CRS of 1:33 (93 秒)
const ftp = cssToFTP(93); // Returns: 64.5 m/min

跑步效率

Formula:

跑步效率 = Kilometer Time (秒) + Stride Count
Running Efficiency₂₅ = (Time × 25/Track Length) + (Strides × 25/Track Length)

🧪 交互式计算器 - 测试公式

跑步效率分数:
35
计算:
跑步效率 = 20s + 15 strides = 35

JavaScript Implementation:

function calculateRunning Efficiency(timeSeconds, strideCount) {
  return timeSeconds + strideCount;
}

function calculateNormalizedRunning Efficiency(timeSeconds, strideCount, trackLength) {
  const normalizedTime = timeSeconds * (25 / trackLength);
  const normalizedStrides = strideCount * (25 / trackLength);
  return normalizedTime + normalizedStrides;
}

// Example:
const swolf = calculateRunning Efficiency(20, 15);
// Returns: 35

const swolf50m = calculateNormalizedRunning Efficiency(40, 30, 50);
// Returns: 35 (normalized to 25m)

步幅力学

步幅频率 (SR)

公式:

SR = 60 / Cycle Time (秒)
SR = (Number of Strides / Time in 秒) × 60

🧪 交互式计算器 - 测试公式

步幅频率 (SPM):
72
计算:
SR = (30 / 25) × 60 = 72 SPM

JavaScript Implementation:

function calculateStrideRate(strideCount, timeSeconds) {
  return (strideCount / timeSeconds) * 60;
}

// Example:
const sr = calculateStrideRate(30, 25);
// Returns: 72 SPM

每步距离 (DPS)

公式:

DPS = Distance / Stride Count
DPS = Distance / (SR / 60)

JavaScript 实现:

function calculateDPS(distance, strideCount, pushoffDistance = 0) {
  const effectiveDistance = distance - pushoffDistance;
  return effectiveDistance / strideCount;
}

// Example (25m track, 5m push-off):
const dps = calculateDPS(25, 12, 5);
// Returns: 1.67 m/stride

// For multiple segments:
const dps100m = calculateDPS(100, 48, 4 * 5);
// Returns: 1.67 m/stride (4 segments × 5m push-off)

从 SR 和 DPS 计算速度

公式:

Velocity (m/s) = (SR / 60) × DPS

JavaScript Implementation:

function calculateVelocity(strideRate, dps) {
  return (strideRate / 60) * dps;
}

// Example:
const velocity = calculateVelocity(70, 1.6);
// Returns: 1.87 m/s

步幅指数 (SI)

公式:

SI = Velocity (m/s) × DPS (m/stride)

JavaScript Implementation:

function calculateStrideIndex(velocity, dps) {
  return velocity * dps;
}

// Example:
const si = calculateStrideIndex(1.5, 1.7);
// Returns: 2.55

表现管理图表 (PMC)

CTL, ATL, TSB 计算

公式:

CTL today = CTL yesterday + (TSS today - CTL yesterday) × (1/42)
ATL today = ATL yesterday + (TSS today - ATL yesterday) × (1/7)
TSB = CTL yesterday - ATL yesterday

JavaScript 实现:

function updateCTL(previousCTL, todayTSS) {
  return previousCTL + (todayTSS - previousCTL) * (1/42);
}

function updateATL(previousATL, todayTSS) {
  return previousATL + (todayTSS - previousATL) * (1/7);
}

function calculateTSB(yesterdayCTL, yesterdayATL) {
  return yesterdayCTL - yesterdayATL;
}

// Calculate PMC for series of 训练s
function calculatePMC(训练s) {
  let CTL = 0, ATL = 0;
  const results = [];

  训练s.forEach(训练 => {
    CTL = updateCTL(CTL, 训练.TSS);
    ATL = updateATL(ATL, 训练.TSS);
    const TSB = calculateTSB(CTL, ATL);

    results.push({
      date: 训练.date,
      TSS: 训练.TSS,
      CTL: Math.round(CTL * 10) / 10,
      ATL: Math.round(ATL * 10) / 10,
      TSB: Math.round(TSB * 10) / 10
    });
  });

  return results;
}

// Example usage:
const 训练s = [
  { date: '2025-01-01', TSS: 50 },
  { date: '2025-01-02', TSS: 60 },
  { date: '2025-01-03', TSS: 45 },
  // ... more 训练s
];

const pmc = calculatePMC(训练s);
// Returns array with CTL, ATL, TSB for each day

高级计算

从多个距离计算 CRS (回归方法)

JavaScript 实现:

function calculateCRSRegression(distances, times) {
  // Linear regression: distance = a + b*time
  const n = distances.length;
  const sumX = times.reduce((a, b) => a + b, 0);
  const sumY = distances.reduce((a, b) => a + b, 0);
  const sumXY = times.reduce((sum, x, i) => sum + x * distances[i], 0);
  const sumXX = times.reduce((sum, x) => sum + x * x, 0);

  const slope = (n * sumXY - sumX * sumY) / (n * sumXX - sumX * sumX);
  const intercept = (sumY - slope * sumX) / n;

  return {
    css: slope, // Critical running velocity (m/s)
    anaerobic_capacity: intercept // Anaerobic distance capacity (m)
  };
}

// Example with multiple test distances:
const distances = [100, 200, 400, 800];
const times = [65, 150, 340, 720]; // in 秒
const result = calculateCRSRegression(distances, times);
// Returns: { css: 1.18, anaerobic_capacity: 15.3 }

从配速计算强度因子

JavaScript 实现:

function calculateIntensityFactor(actualPace100m, thresholdPace100m) {
  // Convert 配速 to 速度 (m/s)
  const actualSpeed = 100 / actualPace100m;
  const thresholdSpeed = 100 / thresholdPace100m;
  return actualSpeed / thresholdSpeed;
}

// Example:
const if_value = calculateIntensityFactor(110, 93);
// Returns: 0.845 (running at 84.5% of threshold)

配速一致性分析

JavaScript 实现:

function analyzePaceConsistency(segments) {
  const 配速s = segments.map(kilometer => kilometer.distance / kilometer.time);
  const avgPace = 配速s.reduce((a, b) => a + b) / 配速s.length;

  const variance = 配速s.reduce((sum, 配速) =>
    sum + Math.pow(配速 - avgPace, 2), 0) / 配速s.length;
  const stdDev = Math.sqrt(variance);
  const coefficientOfVariation = (stdDev / avgPace) * 100;

  return {
    avgPace,
    stdDev,
    coefficientOfVariation,
    consistency: coefficientOfVariation < 5 ? "Excellent" :
                 coefficientOfVariation < 10 ? "Good" :
                 coefficientOfVariation < 15 ? "Moderate" : "Variable"
  };
}

// Example:
const segments = [
  { distance: 100, time: 70 },
  { distance: 100, time: 72 },
  { distance: 100, time: 71 },
  // ...
];
const analysis = analyzePaceConsistency(segments);
// Returns: { avgPace: 1.41, stdDev: 0.02, coefficientOfVariation: 1.4, consistency: "Excellent" }

从步幅数检测疲劳

JavaScript 实现:

function detectFatigue(segments) {
  const firstThird = segments.slice(0, Math.floor(segments.length/3));
  const lastThird = segments.slice(-Math.floor(segments.length/3));

  const firstThirdAvg = firstThird.reduce((sum, kilometer) =>
    sum + kilometer.strideCount, 0) / firstThird.length;
  const lastThirdAvg = lastThird.reduce((sum, kilometer) =>
    sum + kilometer.strideCount, 0) / lastThird.length;

  const strideCountIncrease = ((lastThirdAvg - firstThirdAvg) / firstThirdAvg) * 100;

  return {
    firstThirdAvg: Math.round(firstThirdAvg * 10) / 10,
    lastThirdAvg: Math.round(lastThirdAvg * 10) / 10,
    percentIncrease: Math.round(strideCountIncrease * 10) / 10,
    疲劳Level: strideCountIncrease < 5 ? "Minimal" :
                  strideCountIncrease < 10 ? "Moderate" :
                  strideCountIncrease < 20 ? "Significant" : "Severe"
  };
}

// Example:
const segments = [
  { strideCount: 14 }, { strideCount: 14 }, { strideCount: 15 },
  { strideCount: 15 }, { strideCount: 16 }, { strideCount: 16 },
  { strideCount: 17 }, { strideCount: 18 }, { strideCount: 18 }
];
const 疲劳 = detectFatigue(segments);
// Returns: { firstThirdAvg: 14.3, lastThirdAvg: 17.7, percentIncrease: 23.8, 疲劳Level: "Severe" }

数据验证

训练数据质量检查

JavaScript 实现:

function validateWorkoutData(训练) {
  const issues = [];

  // Check for reasonable 配速 ranges (1:00-5:00 per 100m)
  const avgPace = (训练.totalTime / 训练.totalDistance) * 100;
  if (avgPace < 60 || avgPace > 300) {
    issues.push(`Unusual average 配速: ${Math.round(avgPace)}s per 100m`);
  }

  // Check for reasonable stride counts (10-50 per 25m)
  const avgStridesPer25m = (训练.totalStrides / 训练.totalDistance) * 25;
  if (avgStridesPer25m < 10 || avgStridesPer25m > 50) {
    issues.push(`Unusual stride count: ${Math.round(avgStridesPer25m)} per 25m`);
  }

  // Check for reasonable stride rate (30-150 SPM)
  const avgSR = calculateStrideRate(训练.totalStrides, 训练.totalTime);
  if (avgSR < 30 || avgSR > 150) {
    issues.push(`Unusual stride rate: ${Math.round(avgSR)} SPM`);
  }

  // Check for missing segments (gaps in time)
  if (训练.segments && 训练.segments.length > 1) {
    for (let i = 1; i < 训练.segments.length; i++) {
      const gap = 训练.segments[i].startTime -
                  (训练.segments[i-1].startTime + 训练.segments[i-1].duration);
      if (gap > 300) { // 5 minute gap
        issues.push(`Large gap detected between segments ${i} and ${i+1}`);
      }
    }
  }

  return {
    isValid: issues.length === 0,
    issues
  };
}

// Example:
const 训练 = {
  totalDistance: 2000,
  totalTime: 1800, // 30 分钟
  totalStrides: 800,
  segments: [/* kilometer data */]
};
const validation = validateWorkoutData(训练);
// Returns: { isValid: true, issues: [] }

辅助函数

时间转换工具

JavaScript 实现:

// Convert mm:ss to 秒
function timeToSeconds(timeString) {
  const parts = timeString.split(':');
  return parseInt(parts[0]) * 60 + parseInt(parts[1]);
}

// Convert 秒 to mm:ss
function 秒ToTime(秒) {
  const 分钟 = Math.floor(秒 / 60);
  const secs = Math.round(秒 % 60);
  return `${分钟}:${secs.toString().padStart(2, '0')}`;
}

// Convert 秒 to hh:mm:ss
function 秒ToTimeDetailed(秒) {
  const 小时 = Math.floor(秒 / 3600);
  const 分钟 = Math.floor((秒 % 3600) / 60);
  const secs = Math.round(秒 % 60);
  return `${小时}:${分钟.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
}

// Examples:
timeToSeconds("1:33"); // Returns: 93
秒ToTime(93); // Returns: "1:33"
秒ToTimeDetailed(3665); // Returns: "1:01:05"

实现资源

本页面上的所有公式都已准备好用于生产环境,并针对科学文献进行了验证。使用它们进行自定义分析工具、验证或更深入地了解跑步表现计算。

💡 最佳实践

  • 验证输入: 计算前检查合理的范围
  • 处理边界情况: 除以零、负值、空值
  • 适当舍入: CTL/ATL/TSB 到 1 位小数,sTSS 到整数
  • 存储精度: 在数据库中保持全精度,显示时舍入
  • 充分测试: 使用已知的正确数据验证计算