算法手册/ 通用方法/ 描述

描述

计算公式

符号

符号含义
n参与计算的有效样本量(剔除缺失后)
xi第 i 个样本的取值
x样本均值
s样本标准差(分母 n−1)
p百分位数,P25、P50、P75 为常用的四分位点
t1−α/2t 分布的双侧临界值(自由度 n−1)

核心公式

公式 (1.1):均值与标准差
\[ \bar{x}=\frac{1}{n}\sum_{i=1}^{n}x_i,\qquad s=\sqrt{\frac{1}{n-1}\sum_{i=1}^{n}\left(x_i-\bar{x}\right)^2} \]
公式 (1.2):均值的标准误与置信区间
\[ \mathrm{SE}=\frac{s}{\sqrt{n}},\qquad \mathrm{CI}=\bar{x}\pm t_{1-\alpha/2,\,n-1}\cdot\mathrm{SE} \]
公式 (1.3):百分位数(线性插值)
\[ P_p=x_{(k)}+\left(h-k+1\right)\left(x_{(k+1)}-x_{(k)}\right),\quad h=(n-1)p,\quad k=\left\lfloor h\right\rfloor+1 \]
公式 (1.4):四分位距与变异系数
\[ \mathrm{IQR}=P_{75}-P_{25},\qquad \mathrm{CV}=\frac{s}{\bar{x}}\ (\bar{x}>0) \]
公式 (1.5):偏度与峰度(G1、G2)
\[ \begin{aligned}g_1&=\frac{n}{(n-1)(n-2)}\sum_{i=1}^{n}\left(\frac{x_i-\bar{x}}{s}\right)^3\\g_2&=\frac{n(n+1)}{(n-1)(n-2)(n-3)}\sum_{i=1}^{n}\left(\frac{x_i-\bar{x}}{s}\right)^4-\frac{3(n-1)^2}{(n-2)(n-3)}\end{aligned} \]

参考文献

  1. Joanes, D. N., & Gill, C. A. (1998). Comparing measures of sample skewness and kurtosis. Journal of the Royal Statistical Society: Series D, 47(1), 183–189.
  2. Hyndman, R. J., & Fan, Y. (1996). Sample quantiles in statistical packages. The American Statistician, 50(4), 361–365.
  3. Tukey, J. W. (1977). Exploratory Data Analysis. Addison-Wesley.

算法参数

参数取值默认影响
百分位数 0–100 的百分数,可写多个(如 5、74、95) 不额外输出 在表中增加 P5、P74 这类列;25/50/75 已在表中,不重复出现。
置信水平 0–1 之间的小数,如 0.9、0.95、0.99 0.95 改变均值置信区间的上下限,不影响均值、标准差等点估计。

验证报告

数据与 R 包

数据文件 description.csv
样本与变量 N = 120;X1、X2、X3 三个定量变量
R 包 e1071 1.7.17

提示词

对 X1、X2、X3 三个变量做描述分析,给出均值、标准差、中位数、四分位数、偏度和峰度,均值置信水平用 95%。

R 代码

library(e1071)
d <- read.csv("description.csv")
x <- d[, c("X1", "X2", "X3")]
print(sapply(x, mean), digits = 15)
print(sapply(x, sd), digits = 15)
print(sapply(x, function(v) sd(v) / sqrt(length(v))), digits = 15)
print(t(sapply(x, function(v) t.test(v)$conf.int)), digits = 15)
print(sapply(x, median), digits = 15)
print(sapply(x, function(v) quantile(v, c(.25, .75), type = 7)), digits = 15)
print(sapply(x, var), digits = 15)
print(sapply(x, skewness, type = 2), digits = 15)
print(sapply(x, kurtosis, type = 2), digits = 15)

对比结果

指标SPSSAUR差值
X1 均值0.10866666670.10866666673.33e−11
X1 标准差0.99305481780.99305481783.69e−12
X1 均值标准误0.09065308740.09065308742.44e−11
X1 CI 下限−0.0708355005−0.07083550054.28e−11
X1 CI 上限0.28816883390.28816883392.39e−11
X1 中位数0.24000000000.24000000000
X1 P25−0.5925000000−0.59250000000
X1 P750.76000000000.76000000000
X1 方差0.98615787110.98615787114.85e−11
X1 偏度0.25117098750.25117098752.76e−12
X1 峰度1.69127675481.69127675484.77e−11
X2 均值−0.0182500000−0.01825000000
X2 标准差0.99374147640.99374147643.47e−11
X2 偏度0.24578974620.24578974623.66e−11
X3 均值0.09050000000.09050000000
X3 标准差1.00047959091.00047959092.14e−11
X3 峰度1.24756580841.24756580844.25e−11

结论:均值、标准差、标准误、置信区间、中位数、四分位数、方差、偏度与峰度均与 R 一致,最大差 2.6e−11(来自输出位数)。

操作手册 问题反馈

引用SPSSAU. 描述:计算公式与参数[EB/OL]. SPSSAU算法手册, 2026-11-20. https://www.spssau.com/algorithm/general/description.html.