You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为单样本t检验引入容差以验证麦克风音高测量准确性

How to Add Tolerance to a One-Sample t-Test for Pitch Accuracy Verification

Great question—this is a super common pitfall with standard one-sample t-tests. The issue is that regular t-tests are built to detect any statistically significant difference from your hypothesized mean (196Hz), not to confirm that differences fall within an acceptable range (your 0.25Hz tolerance). When you have a large enough sample size, even tiny, practically irrelevant differences will trigger a tiny p-value, which isn't what you care about here.

Instead, you need to use equivalence testing—specifically the Two One-Sided Tests (TOST) method, which is the gold standard for this kind of "is the difference small enough?" question. Here's how it works:

Step 1: Define Your Tolerance Boundaries

First, formalize your acceptable range. You said you're okay with a 0.25Hz deviation, so your equivalence bounds are:

  • Lower bound: 196 - 0.25 = 195.75Hz
  • Upper bound: 196 + 0.25 = 196.25Hz (even though you intentionally lowered the pitch, using a two-sided bound keeps things rigorous for future tests)

Step 2: Run the TOST Procedure

TOST works by running two separate one-sided t-tests, then combining their results:

  1. First test: Null hypothesis (H0₁) = "Sample mean ≤ 195.75Hz"; Alternative hypothesis (H₁₁) = "Sample mean > 195.75Hz"
  2. Second test: Null hypothesis (H0₂) = "Sample mean ≥ 196.25Hz"; Alternative hypothesis (H₁₂) = "Sample mean < 196.25Hz"

How to Interpret Results

If both tests return p-values less than your chosen significance level (usually α=0.05), you can reject the null hypothesis that the mean is outside your tolerance range. In plain terms: this means your microphone's recorded pitch is within the acceptable 0.25Hz deviation from 196Hz.

Step 3: Implementing TOST in Code

Here are quick examples in two common stats languages:

R (using the TOSTER package)

# Install the package if you haven't already
install.packages("TOSTER")
library(TOSTER)

# Assume your pitch samples are stored in a vector called pitch_samples
tost_result <- TOST_one(
  mu = 196,               # Your hypothesized mean
  m = mean(pitch_samples),# Sample mean
  sd = sd(pitch_samples), # Sample standard deviation
  n = length(pitch_samples), # Sample size
  eqb = 0.25,             # Your tolerance (equivalence bound)
  alpha = 0.05            # Significance level
)

# Print the results
print(tost_result)

Python (using the pingouin library)

# Install the package if needed
# !pip install pingouin
import pingouin as pg
import numpy as np

# Assume pitch_samples is your array of recorded pitch values
tost_result = pg.ttost(
  pitch_samples,
  popmean=196,            # Hypothesized mean
  low=195.75,             # Lower tolerance bound
  high=196.25,            # Upper tolerance bound
  alpha=0.05              # Significance level
)

# View the results
print(tost_result)

Alternative: Confidence Interval Check

A simpler (but equivalent) way to verify this is to calculate the 95% confidence interval of your sample mean. If the entire interval falls inside your 195.75–196.25Hz range, you can conclude the pitch is within your acceptable tolerance.

For example, if your sample mean's 95% CI is (195.8, 195.9), that's fully within your bounds—success!


内容的提问来源于stack exchange,提问作者D. Cohen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 04:29:54