From b466a7d0af8efe660ad70255c3fc7ec6c3ad7c31 Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Mon, 23 Mar 2026 17:10:07 +0800 Subject: [PATCH 01/20] Create reg_pb.sas --- src/gbk/reg_pb.sas | 150 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 src/gbk/reg_pb.sas diff --git a/src/gbk/reg_pb.sas b/src/gbk/reg_pb.sas new file mode 100644 index 0000000..0f93674 --- /dev/null +++ b/src/gbk/reg_pb.sas @@ -0,0 +1,150 @@ +/* + * Macro Name: reg_pb + * Macro Purpose: Passing-Bablok 回归 + * Author: wtwang + * Version Date: 2026-03-23 +*/ + +%macro reg_pb(indata, outdata, x, y, alpha = 0.05, debug = false) / parmbuff; + /* indata: 数据集名称 + * outdata: 保存回归分析结果的数据集名称 + * x: x 轴变量 + * y: y 轴变量 + * alpha: 双侧显著性水平,默认为 0.05 + * debug: 调试模式 + */ + + /*统一参数大小写*/ + %let indata = %sysfunc(strip(%superq(indata))); + %let outdata = %sysfunc(strip(%superq(outdata))); + %let x = %upcase(%sysfunc(strip(%bquote(&x)))); + %let y = %upcase(%sysfunc(strip(%bquote(&y)))); + %let alpha = %sysfunc(strip(%bquote(&alpha))); + %let debug = %upcase(%sysfunc(strip(%bquote(&debug)))); + + /*复制 indata*/ + data tmp_indata; + set %superq(indata) end = end; + _seq = _n_; + if end then call symputx("n", _n_); + run; + + /*点和点进行配对*/ + proc sql noprint; + create table tmp_indata_paired as + select + p1._seq as p1_seq label = "第一个点的序号", + p1.&x as p1_x label = "第一个点的 x 值", + p1.&y as p1_y label = "第一个点的 y 值", + p2._seq as p2_seq label = "第二个点的序号", + p2.&x as p2_x label = "第二个点的 x 值", + p2.&y as p2_y label = "第二个点的 y 值", + ifc(p1_x = p2_x and p1_y = p2_y, "Y", "") as flag_overlap label = "标识变量-重合的点", + ifc(p1_x = p2_x and p1_y < p2_y, "Y", "") as flag_neg_inf label = "标识变量-负无穷大", + ifc(p1_x = p2_x and p1_y > p2_y, "Y", "") as flag_pos_inf label = "标识变量-正无穷大", + ifn(calculated flag_overlap ^= "Y" and + calculated flag_pos_inf ^= "Y" and + calculated flag_neg_inf ^= "Y", (p2_y - p1_y)/(p2_x - p1_x), .) + as slope label = "斜率", + ifc(not missing(calculated slope) and calculated slope = -1, "Y", "") + as flag_slope_eq_minus_one label = "标识变量-斜率等于负一", + (case when calculated flag_neg_inf = "Y" then 1 + when calculated flag_pos_inf = "Y" then 3 + else 2 + end) as flag_sort label = "标识变量-排列顺序" + from tmp_indata as p1, tmp_indata as p2 + where (p1_seq < p2_seq) and calculated flag_overlap ^= "Y" and calculated flag_slope_eq_minus_one ^= "Y" + order by flag_sort, slope; + + /*计算对子数*/ + select count(*) into :M trimmed from tmp_indata_paired; + + /*记录对子在序列中的位置*/ + alter table tmp_indata_paired add seq num(8); + update tmp_indata_paired set seq = monotonic(); + quit; + + /*计算斜率小于 -1 的点对数*/ + proc sql noprint; + select sum((not missing(slope) and slope < -1) or flag_neg_inf = "Y") into :K trimmed from tmp_indata_paired; + quit; + + /*创建存储参数估计值的数据集*/ + proc sql noprint; + create table tmp_parameter_estimate + (param char(20), name char(20), estimate num(8), lower num(8), upper num(8)); + quit; + + /*点估计-斜率*/ + proc sql noprint; + insert into tmp_parameter_estimate + set param = "斜率", name = "slope", estimate = (case when mod(&M, 2) = 1 then (select slope from tmp_indata_paired where seq = (&M + 1)/2 + &K) + when mod(&M, 2) = 0 then ((select slope from tmp_indata_paired where seq = (&M/2 + &K)) + + (select slope from tmp_indata_paired where seq = (&M/2 + 1 + &K))) / 2 + end); + quit; + + /*点估计-截距*/ + proc sql noprint; + create table tmp_indata_intercept_est as + select + &x, + &y, + &y - (select estimate from tmp_parameter_estimate where name = "slope") * &x as intercept_individual + from tmp_indata; + insert into tmp_parameter_estimate + set param = "截距", name = "intercept", estimate = (select median(intercept_individual) from tmp_indata_intercept_est); + quit; + + /*区间估计-斜率*/ + data _null_; + C = probit(1 - &alpha / 2) * sqrt(&n * (&n - 1) * (2 * &n + 5) / 18); + M1 = round((&M - C) / 2); + M2 = &M - M1 + 1; + call symputx("M1", M1); + call symputx("M2", M2); + run; + proc sql noprint; + update tmp_parameter_estimate + set lower = (select slope from tmp_indata_paired where seq = &M1 + &K), + upper = (select slope from tmp_indata_paired where seq = &M2 + &K) + where name = "slope"; + quit; + + /*区间估计-截距*/ + proc sql noprint; + create table tmp_indata_intercept_ci_est as + select + &x, + &y, + &y - (select upper from tmp_parameter_estimate where name = "slope") * &x as intercept_lower_individual, + &y - (select lower from tmp_parameter_estimate where name = "slope") * &x as intercept_upper_individual + from tmp_indata; + update tmp_parameter_estimate + set lower = (select median(intercept_lower_individual) from tmp_indata_intercept_ci_est), + upper = (select median(intercept_upper_individual) from tmp_indata_intercept_ci_est) + where name = "intercept"; + quit; + + /*输出数据集*/ + data &outdata; + set tmp_parameter_estimate; + run; + + /*删除中间数据集*/ + %if %bquote(&debug) = %upcase(false) %then %do; + proc datasets library = work nowarn noprint; + delete tmp_indata + tmp_indata_paired + tmp_parameter_estimate + tmp_indata_intercept_est + tmp_indata_intercept_ci_est + ; + quit; + %end; + + %exit: + %put NOTE: 宏程序 reg_pb 已结束运行!; +%mend; + +%reg_pb(indata = adeff, outdata = pb_res, x = crcd1, y = trcd1, debug = true); From 76a9546d0774802fb0eb56e908a9c3ae3c035fdc Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 11:01:23 +0800 Subject: [PATCH 02/20] update --- README.md | 9 +-- docs/reg_pb.md | 144 +++++++++++++++++++++++++++++++++++++++++++++ src/gbk/reg_pb.sas | 41 +++++++++---- 3 files changed, 178 insertions(+), 16 deletions(-) create mode 100644 docs/reg_pb.md diff --git a/README.md b/README.md index 2e6cfb6..8713033 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # ae-summary -| 馃З 绋嬪簭鍚嶇О | 鉁 鎻忚堪 | 馃摎 鏂囨。 | -| ----------- | ---------------------------------------------- | ------------------ | -| `%ass2` | 鎸夌郴缁熷櫒瀹樺垎绫汇侀閫夋湳璇眹鎬讳笉鑹簨浠 | [鈫楋笍](docs/ass2.md) | -| `%ass3` | 鎸夌郴缁熷櫒瀹樺垎绫汇侀閫夋湳璇佷弗閲嶇▼搴︽眹鎬讳笉鑹簨浠 | [鈫楋笍](docs/ass3.md) | +| 馃З 绋嬪簭鍚嶇О | 鉁 鎻忚堪 | 馃摎 鏂囨。 | +| ----------- | ---------------------------------------------- | -------------------- | +| `%ass2` | 鎸夌郴缁熷櫒瀹樺垎绫汇侀閫夋湳璇眹鎬讳笉鑹簨浠 | [鈫楋笍](docs/ass2.md) | +| `%ass3` | 鎸夌郴缁熷櫒瀹樺垎绫汇侀閫夋湳璇佷弗閲嶇▼搴︽眹鎬讳笉鑹簨浠 | [鈫楋笍](docs/ass3.md) | +| `%reg_pb` | Psssing-Bablok 鍥炲綊 | [鈫楋笍](docs/reg_pb.md) | diff --git a/docs/reg_pb.md b/docs/reg_pb.md new file mode 100644 index 0000000..757cf86 --- /dev/null +++ b/docs/reg_pb.md @@ -0,0 +1,144 @@ +# %reg_pb + +## 绠浠 + +Passing-Bablok 鍥炲綊锛岃绠楁枩鐜囧拰鎴窛锛屽強鍏 95% 缃俊鍖洪棿銆 + +## 璇硶 + +### 鍙傛暟 + +#### 蹇呴夊弬鏁 + +- [indata](#indata) +- [outdata](#outdata) +- [x](#x) +- [y](#y) + +#### 鍙夊弬鏁 + +- [alpha](#alpha) +- [format](#format) + +#### 璋冭瘯鍙傛暟 + +- [debug](#debug) + +### 鍙傛暟璇存槑 + +#### indata + +**Syntax** : _data-set-name_<(_data-set-option_)> + +鎸囧畾寰呭垎鏋愮殑鏁版嵁闆嗭紝鍙娇鐢ㄦ暟鎹泦閫夐」銆 + +**Usage** : + +```sas +indata = adeff +``` + +--- + +#### outdata + +**Syntax** : _data-set-name_<(_data-set-option_)> + +鎸囧畾淇濆瓨姹囨荤粨鏋滅殑鏁版嵁闆嗭紝鍙娇鐢ㄦ暟鎹泦閫夐」銆 + +姹囨荤粨鏋滅殑鏁版嵁闆嗗寘鍚互涓嬪彉閲忥細 + +| 鍙橀噺鍚 | 鍚箟 | +| -------------- | ----------- | +| _param_ | 鍙傛暟 | +| _desc_ | 鍙傛暟鎻忚堪 | +| _estimate_ | 浼拌鍊 | +| _lower_ | 涓嬮檺 | +| _upper_ | 涓婇檺 | +| _estimate_fmt_ | 浼拌鍊硷紙C锛 | +| _lower_fmt_ | 涓嬮檺锛圕锛 | +| _upper_fmt_ | 涓婇檺锛圕锛 | + +**Usage** : + +```sas +outdata = t_5_4_1_2 +``` + +--- + +#### x + +**Syntax** : _variable_ + +鎸囧畾 x 杞村彉閲忥紝鍦ㄤ綋澶栬瘖鏂瘯鍓備复搴婅瘯楠屼腑锛岄氬父鏄姣旇瘯鍓傛娴嬬粨鏋溿 + +**Default** : `crcd1` + +**Usage** : + +```sas +x = crcd1 +``` + +--- + +#### y + +**Syntax** : _variable_ + +鎸囧畾 y 杞村彉閲忥紝鍦ㄤ綋澶栬瘖鏂瘯鍓備复搴婅瘯楠屼腑锛岄氬父鏄冩牳璇曞墏妫娴嬬粨鏋溿 + +**Default** : `trcd1` + +**Usage** : + +```sas +y = trcd1 +``` + +--- + +#### alpha + +**Syntax**: _numeric_ + +鎸囧畾鏄捐憲鎬ф按骞炽 + +**Default** : `0.05` + +**Usage** : + +```sas +alpha = 0.05 +``` + +--- + +#### format + +**Syntax** : _format_ + +鎸囧畾浼拌鍊煎拰缃俊鍖洪棿涓婁笅闄愮殑杈撳嚭鏍煎紡銆 + +**Default** : `8.4` + +**Usage** : + +```sas +format_freq = percentn9.2 +``` + +--- + +#### debug + +**Syntax** : `true` | `false` + +鎸囧畾鏄惁鍚敤璋冭瘯妯″紡銆 + +**Default** : `false` + +> [!NOTE] +> +> 杩欐槸涓涓敤浜庡紑鍙戣呰皟璇曠殑鍙傛暟锛岄氬父涓嶉渶瑕佸叧娉ㄣ diff --git a/src/gbk/reg_pb.sas b/src/gbk/reg_pb.sas index 0f93674..42bd511 100644 --- a/src/gbk/reg_pb.sas +++ b/src/gbk/reg_pb.sas @@ -5,12 +5,13 @@ * Version Date: 2026-03-23 */ -%macro reg_pb(indata, outdata, x, y, alpha = 0.05, debug = false) / parmbuff; +%macro reg_pb(indata, outdata, x, y, alpha = 0.05, format = 8.4, debug = false) / parmbuff; /* indata: 数据集名称 * outdata: 保存回归分析结果的数据集名称 * x: x 轴变量 * y: y 轴变量 * alpha: 双侧显著性水平,默认为 0.05 + * format: 统计量输出格式,默认为 8.4 * debug: 调试模式 */ @@ -20,8 +21,10 @@ %let x = %upcase(%sysfunc(strip(%bquote(&x)))); %let y = %upcase(%sysfunc(strip(%bquote(&y)))); %let alpha = %sysfunc(strip(%bquote(&alpha))); + %let format = %upcase(%sysfunc(strip(%bquote(&format)))); %let debug = %upcase(%sysfunc(strip(%bquote(&debug)))); + /*复制 indata*/ data tmp_indata; set %superq(indata) end = end; @@ -60,7 +63,7 @@ select count(*) into :M trimmed from tmp_indata_paired; /*记录对子在序列中的位置*/ - alter table tmp_indata_paired add seq num(8); + alter table tmp_indata_paired add seq num(8) label = "点对子序号"; update tmp_indata_paired set seq = monotonic(); quit; @@ -72,13 +75,20 @@ /*创建存储参数估计值的数据集*/ proc sql noprint; create table tmp_parameter_estimate - (param char(20), name char(20), estimate num(8), lower num(8), upper num(8)); + (param char(20) label = "参数", + desc char(20) label = "参数描述", + estimate num(8) label = "估计值", + lower num(8) label = "下限", + upper num(8) label = "上限", + estimate_fmt char(20) label = "估计值(C)", + lower_fmt char(20) label = "下限(C)", + upper_fmt char(20) label = "上限(C)"); quit; /*点估计-斜率*/ proc sql noprint; insert into tmp_parameter_estimate - set param = "斜率", name = "slope", estimate = (case when mod(&M, 2) = 1 then (select slope from tmp_indata_paired where seq = (&M + 1)/2 + &K) + set param = "slope", desc = "斜率", estimate = (case when mod(&M, 2) = 1 then (select slope from tmp_indata_paired where seq = (&M + 1)/2 + &K) when mod(&M, 2) = 0 then ((select slope from tmp_indata_paired where seq = (&M/2 + &K)) + (select slope from tmp_indata_paired where seq = (&M/2 + 1 + &K))) / 2 end); @@ -90,10 +100,10 @@ select &x, &y, - &y - (select estimate from tmp_parameter_estimate where name = "slope") * &x as intercept_individual + &y - (select estimate from tmp_parameter_estimate where param = "slope") * &x as intercept_individual label = "在个体样本上计算的截距" from tmp_indata; insert into tmp_parameter_estimate - set param = "截距", name = "intercept", estimate = (select median(intercept_individual) from tmp_indata_intercept_est); + set param = "intercept", desc = "截距", estimate = (select median(intercept_individual) from tmp_indata_intercept_est); quit; /*区间估计-斜率*/ @@ -108,7 +118,7 @@ update tmp_parameter_estimate set lower = (select slope from tmp_indata_paired where seq = &M1 + &K), upper = (select slope from tmp_indata_paired where seq = &M2 + &K) - where name = "slope"; + where param = "slope"; quit; /*区间估计-截距*/ @@ -117,15 +127,24 @@ select &x, &y, - &y - (select upper from tmp_parameter_estimate where name = "slope") * &x as intercept_lower_individual, - &y - (select lower from tmp_parameter_estimate where name = "slope") * &x as intercept_upper_individual + &y - (select upper from tmp_parameter_estimate where param = "slope") * &x as intercept_lower_individual label = "在个体样本上计算的截距下限", + &y - (select lower from tmp_parameter_estimate where param = "slope") * &x as intercept_upper_individual label = "在个体样本上计算的截距上限" from tmp_indata; update tmp_parameter_estimate set lower = (select median(intercept_lower_individual) from tmp_indata_intercept_ci_est), upper = (select median(intercept_upper_individual) from tmp_indata_intercept_ci_est) - where name = "intercept"; + where param = "intercept"; quit; + /*格式化*/ + proc sql noprint; + update tmp_parameter_estimate + set estimate_fmt = put(estimate, &format -L), + lower_fmt = put(lower, &format -L), + upper_fmt = put(upper, &format -L); + quit; + + /*输出数据集*/ data &outdata; set tmp_parameter_estimate; @@ -146,5 +165,3 @@ %exit: %put NOTE: 宏程序 reg_pb 已结束运行!; %mend; - -%reg_pb(indata = adeff, outdata = pb_res, x = crcd1, y = trcd1, debug = true); From 2c23b6f28a7f9a6af1eb541685203bb7b760164e Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 11:01:49 +0800 Subject: [PATCH 03/20] Update reg_pb.sas --- src/gbk/reg_pb.sas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gbk/reg_pb.sas b/src/gbk/reg_pb.sas index 42bd511..fac4857 100644 --- a/src/gbk/reg_pb.sas +++ b/src/gbk/reg_pb.sas @@ -2,7 +2,7 @@ * Macro Name: reg_pb * Macro Purpose: Passing-Bablok 回归 * Author: wtwang - * Version Date: 2026-03-23 + * Version Date: 2026-03-24 */ %macro reg_pb(indata, outdata, x, y, alpha = 0.05, format = 8.4, debug = false) / parmbuff; From e48cf5421ba87b1d74fbecebfc53c98acd06b096 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 24 Mar 2026 03:02:34 +0000 Subject: [PATCH 04/20] chore: multi encoding version --- src/gb18030/reg_pb.sas | 167 +++++++++++++++++++++++++++++++++++++++++ src/gb2312/reg_pb.sas | 167 +++++++++++++++++++++++++++++++++++++++++ src/utf8/reg_pb.sas | 167 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 501 insertions(+) create mode 100644 src/gb18030/reg_pb.sas create mode 100644 src/gb2312/reg_pb.sas create mode 100644 src/utf8/reg_pb.sas diff --git a/src/gb18030/reg_pb.sas b/src/gb18030/reg_pb.sas new file mode 100644 index 0000000..fac4857 --- /dev/null +++ b/src/gb18030/reg_pb.sas @@ -0,0 +1,167 @@ +/* + * Macro Name: reg_pb + * Macro Purpose: Passing-Bablok 回归 + * Author: wtwang + * Version Date: 2026-03-24 +*/ + +%macro reg_pb(indata, outdata, x, y, alpha = 0.05, format = 8.4, debug = false) / parmbuff; + /* indata: 数据集名称 + * outdata: 保存回归分析结果的数据集名称 + * x: x 轴变量 + * y: y 轴变量 + * alpha: 双侧显著性水平,默认为 0.05 + * format: 统计量输出格式,默认为 8.4 + * debug: 调试模式 + */ + + /*统一参数大小写*/ + %let indata = %sysfunc(strip(%superq(indata))); + %let outdata = %sysfunc(strip(%superq(outdata))); + %let x = %upcase(%sysfunc(strip(%bquote(&x)))); + %let y = %upcase(%sysfunc(strip(%bquote(&y)))); + %let alpha = %sysfunc(strip(%bquote(&alpha))); + %let format = %upcase(%sysfunc(strip(%bquote(&format)))); + %let debug = %upcase(%sysfunc(strip(%bquote(&debug)))); + + + /*复制 indata*/ + data tmp_indata; + set %superq(indata) end = end; + _seq = _n_; + if end then call symputx("n", _n_); + run; + + /*点和点进行配对*/ + proc sql noprint; + create table tmp_indata_paired as + select + p1._seq as p1_seq label = "第一个点的序号", + p1.&x as p1_x label = "第一个点的 x 值", + p1.&y as p1_y label = "第一个点的 y 值", + p2._seq as p2_seq label = "第二个点的序号", + p2.&x as p2_x label = "第二个点的 x 值", + p2.&y as p2_y label = "第二个点的 y 值", + ifc(p1_x = p2_x and p1_y = p2_y, "Y", "") as flag_overlap label = "标识变量-重合的点", + ifc(p1_x = p2_x and p1_y < p2_y, "Y", "") as flag_neg_inf label = "标识变量-负无穷大", + ifc(p1_x = p2_x and p1_y > p2_y, "Y", "") as flag_pos_inf label = "标识变量-正无穷大", + ifn(calculated flag_overlap ^= "Y" and + calculated flag_pos_inf ^= "Y" and + calculated flag_neg_inf ^= "Y", (p2_y - p1_y)/(p2_x - p1_x), .) + as slope label = "斜率", + ifc(not missing(calculated slope) and calculated slope = -1, "Y", "") + as flag_slope_eq_minus_one label = "标识变量-斜率等于负一", + (case when calculated flag_neg_inf = "Y" then 1 + when calculated flag_pos_inf = "Y" then 3 + else 2 + end) as flag_sort label = "标识变量-排列顺序" + from tmp_indata as p1, tmp_indata as p2 + where (p1_seq < p2_seq) and calculated flag_overlap ^= "Y" and calculated flag_slope_eq_minus_one ^= "Y" + order by flag_sort, slope; + + /*计算对子数*/ + select count(*) into :M trimmed from tmp_indata_paired; + + /*记录对子在序列中的位置*/ + alter table tmp_indata_paired add seq num(8) label = "点对子序号"; + update tmp_indata_paired set seq = monotonic(); + quit; + + /*计算斜率小于 -1 的点对数*/ + proc sql noprint; + select sum((not missing(slope) and slope < -1) or flag_neg_inf = "Y") into :K trimmed from tmp_indata_paired; + quit; + + /*创建存储参数估计值的数据集*/ + proc sql noprint; + create table tmp_parameter_estimate + (param char(20) label = "参数", + desc char(20) label = "参数描述", + estimate num(8) label = "估计值", + lower num(8) label = "下限", + upper num(8) label = "上限", + estimate_fmt char(20) label = "估计值(C)", + lower_fmt char(20) label = "下限(C)", + upper_fmt char(20) label = "上限(C)"); + quit; + + /*点估计-斜率*/ + proc sql noprint; + insert into tmp_parameter_estimate + set param = "slope", desc = "斜率", estimate = (case when mod(&M, 2) = 1 then (select slope from tmp_indata_paired where seq = (&M + 1)/2 + &K) + when mod(&M, 2) = 0 then ((select slope from tmp_indata_paired where seq = (&M/2 + &K)) + + (select slope from tmp_indata_paired where seq = (&M/2 + 1 + &K))) / 2 + end); + quit; + + /*点估计-截距*/ + proc sql noprint; + create table tmp_indata_intercept_est as + select + &x, + &y, + &y - (select estimate from tmp_parameter_estimate where param = "slope") * &x as intercept_individual label = "在个体样本上计算的截距" + from tmp_indata; + insert into tmp_parameter_estimate + set param = "intercept", desc = "截距", estimate = (select median(intercept_individual) from tmp_indata_intercept_est); + quit; + + /*区间估计-斜率*/ + data _null_; + C = probit(1 - &alpha / 2) * sqrt(&n * (&n - 1) * (2 * &n + 5) / 18); + M1 = round((&M - C) / 2); + M2 = &M - M1 + 1; + call symputx("M1", M1); + call symputx("M2", M2); + run; + proc sql noprint; + update tmp_parameter_estimate + set lower = (select slope from tmp_indata_paired where seq = &M1 + &K), + upper = (select slope from tmp_indata_paired where seq = &M2 + &K) + where param = "slope"; + quit; + + /*区间估计-截距*/ + proc sql noprint; + create table tmp_indata_intercept_ci_est as + select + &x, + &y, + &y - (select upper from tmp_parameter_estimate where param = "slope") * &x as intercept_lower_individual label = "在个体样本上计算的截距下限", + &y - (select lower from tmp_parameter_estimate where param = "slope") * &x as intercept_upper_individual label = "在个体样本上计算的截距上限" + from tmp_indata; + update tmp_parameter_estimate + set lower = (select median(intercept_lower_individual) from tmp_indata_intercept_ci_est), + upper = (select median(intercept_upper_individual) from tmp_indata_intercept_ci_est) + where param = "intercept"; + quit; + + /*格式化*/ + proc sql noprint; + update tmp_parameter_estimate + set estimate_fmt = put(estimate, &format -L), + lower_fmt = put(lower, &format -L), + upper_fmt = put(upper, &format -L); + quit; + + + /*输出数据集*/ + data &outdata; + set tmp_parameter_estimate; + run; + + /*删除中间数据集*/ + %if %bquote(&debug) = %upcase(false) %then %do; + proc datasets library = work nowarn noprint; + delete tmp_indata + tmp_indata_paired + tmp_parameter_estimate + tmp_indata_intercept_est + tmp_indata_intercept_ci_est + ; + quit; + %end; + + %exit: + %put NOTE: 宏程序 reg_pb 已结束运行!; +%mend; diff --git a/src/gb2312/reg_pb.sas b/src/gb2312/reg_pb.sas new file mode 100644 index 0000000..fac4857 --- /dev/null +++ b/src/gb2312/reg_pb.sas @@ -0,0 +1,167 @@ +/* + * Macro Name: reg_pb + * Macro Purpose: Passing-Bablok 回归 + * Author: wtwang + * Version Date: 2026-03-24 +*/ + +%macro reg_pb(indata, outdata, x, y, alpha = 0.05, format = 8.4, debug = false) / parmbuff; + /* indata: 数据集名称 + * outdata: 保存回归分析结果的数据集名称 + * x: x 轴变量 + * y: y 轴变量 + * alpha: 双侧显著性水平,默认为 0.05 + * format: 统计量输出格式,默认为 8.4 + * debug: 调试模式 + */ + + /*统一参数大小写*/ + %let indata = %sysfunc(strip(%superq(indata))); + %let outdata = %sysfunc(strip(%superq(outdata))); + %let x = %upcase(%sysfunc(strip(%bquote(&x)))); + %let y = %upcase(%sysfunc(strip(%bquote(&y)))); + %let alpha = %sysfunc(strip(%bquote(&alpha))); + %let format = %upcase(%sysfunc(strip(%bquote(&format)))); + %let debug = %upcase(%sysfunc(strip(%bquote(&debug)))); + + + /*复制 indata*/ + data tmp_indata; + set %superq(indata) end = end; + _seq = _n_; + if end then call symputx("n", _n_); + run; + + /*点和点进行配对*/ + proc sql noprint; + create table tmp_indata_paired as + select + p1._seq as p1_seq label = "第一个点的序号", + p1.&x as p1_x label = "第一个点的 x 值", + p1.&y as p1_y label = "第一个点的 y 值", + p2._seq as p2_seq label = "第二个点的序号", + p2.&x as p2_x label = "第二个点的 x 值", + p2.&y as p2_y label = "第二个点的 y 值", + ifc(p1_x = p2_x and p1_y = p2_y, "Y", "") as flag_overlap label = "标识变量-重合的点", + ifc(p1_x = p2_x and p1_y < p2_y, "Y", "") as flag_neg_inf label = "标识变量-负无穷大", + ifc(p1_x = p2_x and p1_y > p2_y, "Y", "") as flag_pos_inf label = "标识变量-正无穷大", + ifn(calculated flag_overlap ^= "Y" and + calculated flag_pos_inf ^= "Y" and + calculated flag_neg_inf ^= "Y", (p2_y - p1_y)/(p2_x - p1_x), .) + as slope label = "斜率", + ifc(not missing(calculated slope) and calculated slope = -1, "Y", "") + as flag_slope_eq_minus_one label = "标识变量-斜率等于负一", + (case when calculated flag_neg_inf = "Y" then 1 + when calculated flag_pos_inf = "Y" then 3 + else 2 + end) as flag_sort label = "标识变量-排列顺序" + from tmp_indata as p1, tmp_indata as p2 + where (p1_seq < p2_seq) and calculated flag_overlap ^= "Y" and calculated flag_slope_eq_minus_one ^= "Y" + order by flag_sort, slope; + + /*计算对子数*/ + select count(*) into :M trimmed from tmp_indata_paired; + + /*记录对子在序列中的位置*/ + alter table tmp_indata_paired add seq num(8) label = "点对子序号"; + update tmp_indata_paired set seq = monotonic(); + quit; + + /*计算斜率小于 -1 的点对数*/ + proc sql noprint; + select sum((not missing(slope) and slope < -1) or flag_neg_inf = "Y") into :K trimmed from tmp_indata_paired; + quit; + + /*创建存储参数估计值的数据集*/ + proc sql noprint; + create table tmp_parameter_estimate + (param char(20) label = "参数", + desc char(20) label = "参数描述", + estimate num(8) label = "估计值", + lower num(8) label = "下限", + upper num(8) label = "上限", + estimate_fmt char(20) label = "估计值(C)", + lower_fmt char(20) label = "下限(C)", + upper_fmt char(20) label = "上限(C)"); + quit; + + /*点估计-斜率*/ + proc sql noprint; + insert into tmp_parameter_estimate + set param = "slope", desc = "斜率", estimate = (case when mod(&M, 2) = 1 then (select slope from tmp_indata_paired where seq = (&M + 1)/2 + &K) + when mod(&M, 2) = 0 then ((select slope from tmp_indata_paired where seq = (&M/2 + &K)) + + (select slope from tmp_indata_paired where seq = (&M/2 + 1 + &K))) / 2 + end); + quit; + + /*点估计-截距*/ + proc sql noprint; + create table tmp_indata_intercept_est as + select + &x, + &y, + &y - (select estimate from tmp_parameter_estimate where param = "slope") * &x as intercept_individual label = "在个体样本上计算的截距" + from tmp_indata; + insert into tmp_parameter_estimate + set param = "intercept", desc = "截距", estimate = (select median(intercept_individual) from tmp_indata_intercept_est); + quit; + + /*区间估计-斜率*/ + data _null_; + C = probit(1 - &alpha / 2) * sqrt(&n * (&n - 1) * (2 * &n + 5) / 18); + M1 = round((&M - C) / 2); + M2 = &M - M1 + 1; + call symputx("M1", M1); + call symputx("M2", M2); + run; + proc sql noprint; + update tmp_parameter_estimate + set lower = (select slope from tmp_indata_paired where seq = &M1 + &K), + upper = (select slope from tmp_indata_paired where seq = &M2 + &K) + where param = "slope"; + quit; + + /*区间估计-截距*/ + proc sql noprint; + create table tmp_indata_intercept_ci_est as + select + &x, + &y, + &y - (select upper from tmp_parameter_estimate where param = "slope") * &x as intercept_lower_individual label = "在个体样本上计算的截距下限", + &y - (select lower from tmp_parameter_estimate where param = "slope") * &x as intercept_upper_individual label = "在个体样本上计算的截距上限" + from tmp_indata; + update tmp_parameter_estimate + set lower = (select median(intercept_lower_individual) from tmp_indata_intercept_ci_est), + upper = (select median(intercept_upper_individual) from tmp_indata_intercept_ci_est) + where param = "intercept"; + quit; + + /*格式化*/ + proc sql noprint; + update tmp_parameter_estimate + set estimate_fmt = put(estimate, &format -L), + lower_fmt = put(lower, &format -L), + upper_fmt = put(upper, &format -L); + quit; + + + /*输出数据集*/ + data &outdata; + set tmp_parameter_estimate; + run; + + /*删除中间数据集*/ + %if %bquote(&debug) = %upcase(false) %then %do; + proc datasets library = work nowarn noprint; + delete tmp_indata + tmp_indata_paired + tmp_parameter_estimate + tmp_indata_intercept_est + tmp_indata_intercept_ci_est + ; + quit; + %end; + + %exit: + %put NOTE: 宏程序 reg_pb 已结束运行!; +%mend; diff --git a/src/utf8/reg_pb.sas b/src/utf8/reg_pb.sas new file mode 100644 index 0000000..8119a65 --- /dev/null +++ b/src/utf8/reg_pb.sas @@ -0,0 +1,167 @@ +/* + * Macro Name: reg_pb + * Macro Purpose: Passing-Bablok 鍥炲綊 + * Author: wtwang + * Version Date: 2026-03-24 +*/ + +%macro reg_pb(indata, outdata, x, y, alpha = 0.05, format = 8.4, debug = false) / parmbuff; + /* indata: 鏁版嵁闆嗗悕绉 + * outdata: 淇濆瓨鍥炲綊鍒嗘瀽缁撴灉鐨勬暟鎹泦鍚嶇О + * x: x 杞村彉閲 + * y: y 杞村彉閲 + * alpha: 鍙屼晶鏄捐憲鎬ф按骞筹紝榛樿涓 0.05 + * format: 缁熻閲忚緭鍑烘牸寮忥紝榛樿涓 8.4 + * debug: 璋冭瘯妯″紡 + */ + + /*缁熶竴鍙傛暟澶у皬鍐*/ + %let indata = %sysfunc(strip(%superq(indata))); + %let outdata = %sysfunc(strip(%superq(outdata))); + %let x = %upcase(%sysfunc(strip(%bquote(&x)))); + %let y = %upcase(%sysfunc(strip(%bquote(&y)))); + %let alpha = %sysfunc(strip(%bquote(&alpha))); + %let format = %upcase(%sysfunc(strip(%bquote(&format)))); + %let debug = %upcase(%sysfunc(strip(%bquote(&debug)))); + + + /*澶嶅埗 indata*/ + data tmp_indata; + set %superq(indata) end = end; + _seq = _n_; + if end then call symputx("n", _n_); + run; + + /*鐐瑰拰鐐硅繘琛岄厤瀵*/ + proc sql noprint; + create table tmp_indata_paired as + select + p1._seq as p1_seq label = "绗竴涓偣鐨勫簭鍙", + p1.&x as p1_x label = "绗竴涓偣鐨 x 鍊", + p1.&y as p1_y label = "绗竴涓偣鐨 y 鍊", + p2._seq as p2_seq label = "绗簩涓偣鐨勫簭鍙", + p2.&x as p2_x label = "绗簩涓偣鐨 x 鍊", + p2.&y as p2_y label = "绗簩涓偣鐨 y 鍊", + ifc(p1_x = p2_x and p1_y = p2_y, "Y", "") as flag_overlap label = "鏍囪瘑鍙橀噺-閲嶅悎鐨勭偣", + ifc(p1_x = p2_x and p1_y < p2_y, "Y", "") as flag_neg_inf label = "鏍囪瘑鍙橀噺-璐熸棤绌峰ぇ", + ifc(p1_x = p2_x and p1_y > p2_y, "Y", "") as flag_pos_inf label = "鏍囪瘑鍙橀噺-姝f棤绌峰ぇ", + ifn(calculated flag_overlap ^= "Y" and + calculated flag_pos_inf ^= "Y" and + calculated flag_neg_inf ^= "Y", (p2_y - p1_y)/(p2_x - p1_x), .) + as slope label = "鏂滅巼", + ifc(not missing(calculated slope) and calculated slope = -1, "Y", "") + as flag_slope_eq_minus_one label = "鏍囪瘑鍙橀噺-鏂滅巼绛変簬璐熶竴", + (case when calculated flag_neg_inf = "Y" then 1 + when calculated flag_pos_inf = "Y" then 3 + else 2 + end) as flag_sort label = "鏍囪瘑鍙橀噺-鎺掑垪椤哄簭" + from tmp_indata as p1, tmp_indata as p2 + where (p1_seq < p2_seq) and calculated flag_overlap ^= "Y" and calculated flag_slope_eq_minus_one ^= "Y" + order by flag_sort, slope; + + /*璁$畻瀵瑰瓙鏁*/ + select count(*) into :M trimmed from tmp_indata_paired; + + /*璁板綍瀵瑰瓙鍦ㄥ簭鍒椾腑鐨勪綅缃*/ + alter table tmp_indata_paired add seq num(8) label = "鐐瑰瀛愬簭鍙"; + update tmp_indata_paired set seq = monotonic(); + quit; + + /*璁$畻鏂滅巼灏忎簬 -1 鐨勭偣瀵规暟*/ + proc sql noprint; + select sum((not missing(slope) and slope < -1) or flag_neg_inf = "Y") into :K trimmed from tmp_indata_paired; + quit; + + /*鍒涘缓瀛樺偍鍙傛暟浼拌鍊肩殑鏁版嵁闆*/ + proc sql noprint; + create table tmp_parameter_estimate + (param char(20) label = "鍙傛暟", + desc char(20) label = "鍙傛暟鎻忚堪", + estimate num(8) label = "浼拌鍊", + lower num(8) label = "涓嬮檺", + upper num(8) label = "涓婇檺", + estimate_fmt char(20) label = "浼拌鍊硷紙C锛", + lower_fmt char(20) label = "涓嬮檺锛圕锛", + upper_fmt char(20) label = "涓婇檺锛圕锛"); + quit; + + /*鐐逛及璁-鏂滅巼*/ + proc sql noprint; + insert into tmp_parameter_estimate + set param = "slope", desc = "鏂滅巼", estimate = (case when mod(&M, 2) = 1 then (select slope from tmp_indata_paired where seq = (&M + 1)/2 + &K) + when mod(&M, 2) = 0 then ((select slope from tmp_indata_paired where seq = (&M/2 + &K)) + + (select slope from tmp_indata_paired where seq = (&M/2 + 1 + &K))) / 2 + end); + quit; + + /*鐐逛及璁-鎴窛*/ + proc sql noprint; + create table tmp_indata_intercept_est as + select + &x, + &y, + &y - (select estimate from tmp_parameter_estimate where param = "slope") * &x as intercept_individual label = "鍦ㄤ釜浣撴牱鏈笂璁$畻鐨勬埅璺" + from tmp_indata; + insert into tmp_parameter_estimate + set param = "intercept", desc = "鎴窛", estimate = (select median(intercept_individual) from tmp_indata_intercept_est); + quit; + + /*鍖洪棿浼拌-鏂滅巼*/ + data _null_; + C = probit(1 - &alpha / 2) * sqrt(&n * (&n - 1) * (2 * &n + 5) / 18); + M1 = round((&M - C) / 2); + M2 = &M - M1 + 1; + call symputx("M1", M1); + call symputx("M2", M2); + run; + proc sql noprint; + update tmp_parameter_estimate + set lower = (select slope from tmp_indata_paired where seq = &M1 + &K), + upper = (select slope from tmp_indata_paired where seq = &M2 + &K) + where param = "slope"; + quit; + + /*鍖洪棿浼拌-鎴窛*/ + proc sql noprint; + create table tmp_indata_intercept_ci_est as + select + &x, + &y, + &y - (select upper from tmp_parameter_estimate where param = "slope") * &x as intercept_lower_individual label = "鍦ㄤ釜浣撴牱鏈笂璁$畻鐨勬埅璺濅笅闄", + &y - (select lower from tmp_parameter_estimate where param = "slope") * &x as intercept_upper_individual label = "鍦ㄤ釜浣撴牱鏈笂璁$畻鐨勬埅璺濅笂闄" + from tmp_indata; + update tmp_parameter_estimate + set lower = (select median(intercept_lower_individual) from tmp_indata_intercept_ci_est), + upper = (select median(intercept_upper_individual) from tmp_indata_intercept_ci_est) + where param = "intercept"; + quit; + + /*鏍煎紡鍖*/ + proc sql noprint; + update tmp_parameter_estimate + set estimate_fmt = put(estimate, &format -L), + lower_fmt = put(lower, &format -L), + upper_fmt = put(upper, &format -L); + quit; + + + /*杈撳嚭鏁版嵁闆*/ + data &outdata; + set tmp_parameter_estimate; + run; + + /*鍒犻櫎涓棿鏁版嵁闆*/ + %if %bquote(&debug) = %upcase(false) %then %do; + proc datasets library = work nowarn noprint; + delete tmp_indata + tmp_indata_paired + tmp_parameter_estimate + tmp_indata_intercept_est + tmp_indata_intercept_ci_est + ; + quit; + %end; + + %exit: + %put NOTE: 瀹忕▼搴 reg_pb 宸茬粨鏉熻繍琛岋紒; +%mend; From f73bd7d47deb43e69c0bd79a8ea66d46ee153049 Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 11:49:46 +0800 Subject: [PATCH 05/20] Update reg_pb.md --- docs/reg_pb.md | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/docs/reg_pb.md b/docs/reg_pb.md index 757cf86..ca3e19f 100644 --- a/docs/reg_pb.md +++ b/docs/reg_pb.md @@ -142,3 +142,75 @@ format_freq = percentn9.2 > [!NOTE] > > 杩欐槸涓涓敤浜庡紑鍙戣呰皟璇曠殑鍙傛暟锛岄氬父涓嶉渶瑕佸叧娉ㄣ + +## Passing-Bablok 鍥炲綊绠楁硶 + +1. 璁炬牱鏈暟閲忎负 $n$ 锛屼换鍙栦袱涓牱鏈 $(x_i, y_i)$ 鍜 $(x_j, y_j)$ 锛屾瀯鎴愪竴涓偣瀵瑰瓙锛屾瘡涓偣瀵瑰瓙鐨勮繛绾块兘鏈変竴涓枩鐜 $S_{ij}$ + + $$ + S_{ij} = \frac{y_i - y_j}{x_i - x_j} \ \ , 1 \le i < j \le n + $$ + + 杩欐牱鐨勭偣瀵瑰瓙涓鍏辨湁 $\mathrm{C}_n^2$ 涓 + +2. 浠ヤ笅涓ょ鐐瑰瀛愰渶瑕佹帓闄わ紝瀹冧滑瀵 Passing-Bablok 鍥炲綊瀵瑰弬鏁扮殑浼拌涓嶄綔璐$尞銆 + - 閲嶅悎鐨勭偣瀵瑰瓙锛屽嵆 $x_i = x_j$ 涓 $y_i = y_j$ 锛 + - 鏂滅巼涓 -1 鐨勭偣瀵瑰瓙锛屽嵆 $S_{ij} = -1$ 锛 + + 璁板墿浣欐牱鏈暟閲忎负 $M$ 銆 + +3. 瀵 $M$ 涓偣瀵瑰瓙鎸夌収鏂滅巼浠庡皬鍒板ぇ鎺掑簭锛屽緱鍒板簭鍒 $S_{(1)} \le S_{(2)} \le \cdots \le S_{(M)}$ 銆 + 瀵逛簬鏂滅巼涓嶅瓨鍦ㄧ殑鐐瑰瀛愶紝澶勭悊鏂瑰紡濡備笅锛 + - 鑻 $x_i = x_j$ 涓 $y_i \gt y_j$ 锛屽垯 $S_{ij} = +\infty$ 锛屽皢璇ョ偣瀵瑰瓙鎺掑湪搴忓垪鏈鍓嶏紱 + - 鑻 $x_i = x_j$ 涓 $y_i \lt y_j$ 锛屽垯 $S_{ij} = -\infty$ 锛屽皢璇ョ偣瀵瑰瓙鎺掑湪搴忓垪鏈鍚庛 + +4. 璁 $S_{ij} \lt -1$ 鐨勭偣瀵瑰瓙鏁伴噺涓 $K$ 锛岀О浣溾滃亸绉婚噺鈥濓紝Passing-Bablok 鍥炲綊鐨勬枩鐜 $b$ 鍙互閫氳繃搴忓垪 $S_{(i)}$ 鐨勫亸绉讳腑浣嶆暟鏉ヤ及璁★細 + + $$ + b = + \begin{cases} + S_{\left(\frac{M + 1}{2} + K\right)}, & \text{if } M \text{ is odd} \\ + \frac{1}{2} \cdot \left( S_{\left(\frac{M}{2} + K\right)} + S_{\left(\frac{M}{2} + 1 + K\right)}\right), & \text{if } M \text{ is even} \\ + \end{cases} + $$ + +5. 浼拌 $b$ 鐨勭疆淇″尯闂 + + $$ + C = Z_{1 - \alpha/2} \sqrt{\frac{n(n - 1)(2n + 5)}{18}} + $$ + + 鍏朵腑 $Z_{1 - \alpha/2}$ 涓烘爣鍑嗘鎬佸垎甯冪殑 $ 1 - \alpha/2$ 鍒嗕綅鏁般 + + $$ + M_1 = \frac{M - C}{2}, \ \ M_2 = M - M_1 + 1 + $$ + + 鍏朵腑锛 $M_1$ 闇瑕佽垗鍏ュ埌鏈鎺ヨ繎鐨勬暣鏁板笺 + + $b$ 鐨勭疆淇″尯闂翠负锛 + + $$ + S_{(M_1 + K)} \le b \le S_{(M_2 + K)} + $$ + +6. 浼拌鎴窛 $a$ 鍙婂叾缃俊鍖洪棿 + + 鎴窛 $a$ 鐨勪及璁″師鐞嗘槸锛氳嚦灏戞湁涓鍗婄殑鐐瑰湪绾 $y = a + bx$ 鐨勪笂鏂癸紝鍙︿竴鍗婂垯鍦ㄧ嚎 $y = a + bx$ 鐨勪笅鏂广 + + 鍋囪姣忎釜鐐归兘鑳借惤鍦ㄧ嚎 $y = a + bx$ 涓婏紝杩涜屽姣忎釜鐐癸紝閮借兘璁$畻涓涓埅璺 $a_i = y_i - bx_i$ 锛屾墍鏈 $a_i$ 浠庡皬鍒板ぇ鎺掑簭锛屽彇涓綅鏁帮紝鍗冲彲寰楀埌鎴窛 $a$ 鐨勪及璁″硷細 + + $$ + a = \text{median}\{y_i - bx_i\} + $$ + + 鎴窛 $a$ 鐨勭疆淇″尯闂翠负锛 + + $$ + a_L = \text{median}\{y_i - b_Ux_i\} \\ + a_U = \text{median}\{y_i - b_Lx_i\} + $$ + +## References + +1. Passing H, Bablok W. A new biometrical procedure for testing the equality of measurements from two different analytical methods. Application of linear regression procedures for method comparison studies in clinical chemistry, Part I[J]. Clinical Chemistry and Laboratory Medicine, 1983, 21(11): 709-720. From 1fd5dcfef47469fd6fc57f439cdd0a807e740fbf Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 12:11:14 +0800 Subject: [PATCH 06/20] Update reg_pb.md --- docs/reg_pb.md | 101 +++++++++++++++++++++++++++---------------------- 1 file changed, 56 insertions(+), 45 deletions(-) diff --git a/docs/reg_pb.md b/docs/reg_pb.md index ca3e19f..19a8c97 100644 --- a/docs/reg_pb.md +++ b/docs/reg_pb.md @@ -145,71 +145,82 @@ format_freq = percentn9.2 ## Passing-Bablok 鍥炲綊绠楁硶 -1. 璁炬牱鏈暟閲忎负 $n$ 锛屼换鍙栦袱涓牱鏈 $(x_i, y_i)$ 鍜 $(x_j, y_j)$ 锛屾瀯鎴愪竴涓偣瀵瑰瓙锛屾瘡涓偣瀵瑰瓙鐨勮繛绾块兘鏈変竴涓枩鐜 $S_{ij}$ +### 1. 鏋勫缓鐐瑰瀛愶紝璁$畻鏂滅巼 - $$ - S_{ij} = \frac{y_i - y_j}{x_i - x_j} \ \ , 1 \le i < j \le n - $$ +璁炬牱鏈暟閲忎负 $n$ 锛屼换鍙栦袱涓牱鏈 $(x_i, y_i)$ 鍜 $(x_j, y_j)$ 锛屾瀯鎴愪竴涓偣瀵瑰瓙锛屾瘡涓偣瀵瑰瓙鐨勮繛绾块兘鏈変竴涓枩鐜 $S_{ij}$ - 杩欐牱鐨勭偣瀵瑰瓙涓鍏辨湁 $\mathrm{C}_n^2$ 涓 +$$ +S_{ij} = \frac{y_i - y_j}{x_i - x_j} \ \ , 1 \le i < j \le n +$$ -2. 浠ヤ笅涓ょ鐐瑰瀛愰渶瑕佹帓闄わ紝瀹冧滑瀵 Passing-Bablok 鍥炲綊瀵瑰弬鏁扮殑浼拌涓嶄綔璐$尞銆 - - 閲嶅悎鐨勭偣瀵瑰瓙锛屽嵆 $x_i = x_j$ 涓 $y_i = y_j$ 锛 - - 鏂滅巼涓 -1 鐨勭偣瀵瑰瓙锛屽嵆 $S_{ij} = -1$ 锛 +杩欐牱鐨勭偣瀵瑰瓙涓鍏辨湁 $\mathrm{C}_n^2$ 涓 - 璁板墿浣欐牱鏈暟閲忎负 $M$ 銆 +### 2. 鎺掗櫎涓嶅仛璐$尞鐨勭偣瀵瑰瓙 -3. 瀵 $M$ 涓偣瀵瑰瓙鎸夌収鏂滅巼浠庡皬鍒板ぇ鎺掑簭锛屽緱鍒板簭鍒 $S_{(1)} \le S_{(2)} \le \cdots \le S_{(M)}$ 銆 - 瀵逛簬鏂滅巼涓嶅瓨鍦ㄧ殑鐐瑰瀛愶紝澶勭悊鏂瑰紡濡備笅锛 - - 鑻 $x_i = x_j$ 涓 $y_i \gt y_j$ 锛屽垯 $S_{ij} = +\infty$ 锛屽皢璇ョ偣瀵瑰瓙鎺掑湪搴忓垪鏈鍓嶏紱 - - 鑻 $x_i = x_j$ 涓 $y_i \lt y_j$ 锛屽垯 $S_{ij} = -\infty$ 锛屽皢璇ョ偣瀵瑰瓙鎺掑湪搴忓垪鏈鍚庛 +浠ヤ笅涓ょ鐐瑰瀛愰渶瑕佹帓闄わ紝瀹冧滑瀵 Passing-Bablok 鍥炲綊瀵瑰弬鏁扮殑浼拌涓嶄綔璐$尞銆 -4. 璁 $S_{ij} \lt -1$ 鐨勭偣瀵瑰瓙鏁伴噺涓 $K$ 锛岀О浣溾滃亸绉婚噺鈥濓紝Passing-Bablok 鍥炲綊鐨勬枩鐜 $b$ 鍙互閫氳繃搴忓垪 $S_{(i)}$ 鐨勫亸绉讳腑浣嶆暟鏉ヤ及璁★細 +- 閲嶅悎鐨勭偣瀵瑰瓙锛屽嵆 $x_i = x_j$ 涓 $y_i = y_j$ 锛 +- 鏂滅巼涓 -1 鐨勭偣瀵瑰瓙锛屽嵆 $S_{ij} = -1$ 锛 - $$ - b = - \begin{cases} - S_{\left(\frac{M + 1}{2} + K\right)}, & \text{if } M \text{ is odd} \\ - \frac{1}{2} \cdot \left( S_{\left(\frac{M}{2} + K\right)} + S_{\left(\frac{M}{2} + 1 + K\right)}\right), & \text{if } M \text{ is even} \\ - \end{cases} - $$ +璁板墿浣欐牱鏈暟閲忎负 $M$ 銆 -5. 浼拌 $b$ 鐨勭疆淇″尯闂 +### 3. 鏋勫缓鏂滅巼搴忓垪 - $$ - C = Z_{1 - \alpha/2} \sqrt{\frac{n(n - 1)(2n + 5)}{18}} - $$ +瀵 $M$ 涓偣瀵瑰瓙鎸夌収鏂滅巼浠庡皬鍒板ぇ鎺掑簭锛屽緱鍒板簭鍒 $S_{(1)} \le S_{(2)} \le \cdots \le S_{(M)}$ 銆 - 鍏朵腑 $Z_{1 - \alpha/2}$ 涓烘爣鍑嗘鎬佸垎甯冪殑 $ 1 - \alpha/2$ 鍒嗕綅鏁般 +瀵逛簬鏂滅巼涓嶅瓨鍦ㄧ殑鐐瑰瀛愶紝澶勭悊鏂瑰紡濡備笅锛 - $$ - M_1 = \frac{M - C}{2}, \ \ M_2 = M - M_1 + 1 - $$ +- 鑻 $x_i = x_j$ 涓 $y_i \gt y_j$ 锛屽垯 $S_{ij} = +\infty$ 锛屽皢璇ョ偣瀵瑰瓙鎺掑湪搴忓垪鏈鍓嶏紱 +- 鑻 $x_i = x_j$ 涓 $y_i \lt y_j$ 锛屽垯 $S_{ij} = -\infty$ 锛屽皢璇ョ偣瀵瑰瓙鎺掑湪搴忓垪鏈鍚庛 - 鍏朵腑锛 $M_1$ 闇瑕佽垗鍏ュ埌鏈鎺ヨ繎鐨勬暣鏁板笺 +### 4. 浼拌鏂滅巼 - $b$ 鐨勭疆淇″尯闂翠负锛 +璁 $S_{ij} \lt -1$ 鐨勭偣瀵瑰瓙鏁伴噺涓 $K$ 锛岀О浣溾滃亸绉婚噺鈥濓紝Passing-Bablok 鍥炲綊鐨勬枩鐜 $b$ 鍙互閫氳繃搴忓垪 $S_{(i)}$ 鐨勫亸绉讳腑浣嶆暟鏉ヤ及璁★細 - $$ - S_{(M_1 + K)} \le b \le S_{(M_2 + K)} - $$ +$$ +b = +\begin{cases} +S_{\left(\frac{M + 1}{2} + K\right)}, & \text{if } M \text{ is odd} \\ +\frac{1}{2} \cdot \left( S_{\left(\frac{M}{2} + K\right)} + S_{\left(\frac{M}{2} + 1 + K\right)}\right), & \text{if } M \text{ is even} \\ +\end{cases} +$$ -6. 浼拌鎴窛 $a$ 鍙婂叾缃俊鍖洪棿 +### 5. 浼拌鏂滅巼鐨勭疆淇″尯闂 - 鎴窛 $a$ 鐨勪及璁″師鐞嗘槸锛氳嚦灏戞湁涓鍗婄殑鐐瑰湪绾 $y = a + bx$ 鐨勪笂鏂癸紝鍙︿竴鍗婂垯鍦ㄧ嚎 $y = a + bx$ 鐨勪笅鏂广 +$$ +C = Z_{1 - \alpha/2} \sqrt{\frac{n(n - 1)(2n + 5)}{18}} +$$ - 鍋囪姣忎釜鐐归兘鑳借惤鍦ㄧ嚎 $y = a + bx$ 涓婏紝杩涜屽姣忎釜鐐癸紝閮借兘璁$畻涓涓埅璺 $a_i = y_i - bx_i$ 锛屾墍鏈 $a_i$ 浠庡皬鍒板ぇ鎺掑簭锛屽彇涓綅鏁帮紝鍗冲彲寰楀埌鎴窛 $a$ 鐨勪及璁″硷細 +鍏朵腑 $Z_{1 - \alpha/2}$ 涓烘爣鍑嗘鎬佸垎甯冪殑 $ 1 - \alpha/2$ 鍒嗕綅鏁般 - $$ - a = \text{median}\{y_i - bx_i\} - $$ +$$ +M_1 = \frac{M - C}{2}, \ \ M_2 = M - M_1 + 1 +$$ - 鎴窛 $a$ 鐨勭疆淇″尯闂翠负锛 +鍏朵腑锛 $M_1$ 闇瑕佽垗鍏ュ埌鏈鎺ヨ繎鐨勬暣鏁板笺 - $$ - a_L = \text{median}\{y_i - b_Ux_i\} \\ - a_U = \text{median}\{y_i - b_Lx_i\} - $$ +$b$ 鐨勭疆淇″尯闂翠负锛 + +$$ +S_{(M_1 + K)} \le b \le S_{(M_2 + K)} +$$ + +### 6. 浼拌鎴窛鍙婂叾缃俊鍖洪棿 + +鎴窛 $a$ 鐨勪及璁″師鐞嗘槸锛氳嚦灏戞湁涓鍗婄殑鐐瑰湪绾 $y = a + bx$ 鐨勪笂鏂癸紝鍙︿竴鍗婂垯鍦ㄧ嚎 $y = a + bx$ 鐨勪笅鏂广 + +鍋囪姣忎釜鐐归兘鑳借惤鍦ㄧ嚎 $y = a + bx$ 涓婏紝杩涜屽姣忎釜鐐癸紝閮借兘璁$畻涓涓埅璺 $a_i = y_i - bx_i$ 锛屾墍鏈 $a_i$ 浠庡皬鍒板ぇ鎺掑簭锛屽彇涓綅鏁帮紝鍗冲彲寰楀埌鎴窛 $a$ 鐨勪及璁″硷細 + +$$ +a = \text{median}\{y_i - bx_i\} +$$ + +鎴窛 $a$ 鐨勭疆淇″尯闂翠负锛 + +$$ +a_L = \text{median}\{y_i - b_Ux_i\} \\ +a_U = \text{median}\{y_i - b_Lx_i\} +$$ ## References From 71abd2dc67ae5806fef1954f58b718d9de92846b Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:03:54 +0800 Subject: [PATCH 07/20] Update reg_pb.md --- docs/reg_pb.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/reg_pb.md b/docs/reg_pb.md index 19a8c97..07b16ce 100644 --- a/docs/reg_pb.md +++ b/docs/reg_pb.md @@ -157,7 +157,7 @@ $$ ### 2. 鎺掗櫎涓嶅仛璐$尞鐨勭偣瀵瑰瓙 -浠ヤ笅涓ょ鐐瑰瀛愰渶瑕佹帓闄わ紝瀹冧滑瀵 Passing-Bablok 鍥炲綊瀵瑰弬鏁扮殑浼拌涓嶄綔璐$尞銆 +浠ヤ笅涓ょ鐐瑰瀛愰渶瑕佹帓闄わ紝瀹冧滑瀵 Passing-Bablok 鍥炲綊鐨勫弬鏁颁及璁′笉浣滆础鐚 - 閲嶅悎鐨勭偣瀵瑰瓙锛屽嵆 $x_i = x_j$ 涓 $y_i = y_j$ 锛 - 鏂滅巼涓 -1 鐨勭偣瀵瑰瓙锛屽嵆 $S_{ij} = -1$ 锛 @@ -188,10 +188,10 @@ $$ ### 5. 浼拌鏂滅巼鐨勭疆淇″尯闂 $$ -C = Z_{1 - \alpha/2} \sqrt{\frac{n(n - 1)(2n + 5)}{18}} +C = Z_{1 - \frac{\alpha}{2}} \sqrt{\frac{n(n - 1)(2n + 5)}{18}} $$ -鍏朵腑 $Z_{1 - \alpha/2}$ 涓烘爣鍑嗘鎬佸垎甯冪殑 $ 1 - \alpha/2$ 鍒嗕綅鏁般 +鍏朵腑 $Z_{1 - \frac{\alpha}{2}}$ 涓烘爣鍑嗘鎬佸垎甯冪殑 $1 - \alpha/2$ 鍒嗕綅鏁般 $$ M_1 = \frac{M - C}{2}, \ \ M_2 = M - M_1 + 1 @@ -218,8 +218,10 @@ $$ 鎴窛 $a$ 鐨勭疆淇″尯闂翠负锛 $$ +\begin{cases} a_L = \text{median}\{y_i - b_Ux_i\} \\ a_U = \text{median}\{y_i - b_Lx_i\} +\end{cases} $$ ## References From 71d6f8584d9a0a00986aa5405cfea3a33a1f3657 Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:04:22 +0800 Subject: [PATCH 08/20] Update reg_pb.md --- docs/reg_pb.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reg_pb.md b/docs/reg_pb.md index 07b16ce..2d07e14 100644 --- a/docs/reg_pb.md +++ b/docs/reg_pb.md @@ -191,7 +191,7 @@ $$ C = Z_{1 - \frac{\alpha}{2}} \sqrt{\frac{n(n - 1)(2n + 5)}{18}} $$ -鍏朵腑 $Z_{1 - \frac{\alpha}{2}}$ 涓烘爣鍑嗘鎬佸垎甯冪殑 $1 - \alpha/2$ 鍒嗕綅鏁般 +鍏朵腑 $Z_{1 - \frac{\alpha}{2}}$ 涓烘爣鍑嗘鎬佸垎甯冪殑 $1 - \frac{\alpha}{2}$ 鍒嗕綅鏁般 $$ M_1 = \frac{M - C}{2}, \ \ M_2 = M - M_1 + 1 From 94791e1a1f41235d95fde14c567e9f9890307b6d Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:06:04 +0800 Subject: [PATCH 09/20] Update reg_pb.md --- docs/reg_pb.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reg_pb.md b/docs/reg_pb.md index 2d07e14..e85df35 100644 --- a/docs/reg_pb.md +++ b/docs/reg_pb.md @@ -170,8 +170,8 @@ $$ 瀵逛簬鏂滅巼涓嶅瓨鍦ㄧ殑鐐瑰瀛愶紝澶勭悊鏂瑰紡濡備笅锛 -- 鑻 $x_i = x_j$ 涓 $y_i \gt y_j$ 锛屽垯 $S_{ij} = +\infty$ 锛屽皢璇ョ偣瀵瑰瓙鎺掑湪搴忓垪鏈鍓嶏紱 -- 鑻 $x_i = x_j$ 涓 $y_i \lt y_j$ 锛屽垯 $S_{ij} = -\infty$ 锛屽皢璇ョ偣瀵瑰瓙鎺掑湪搴忓垪鏈鍚庛 +- 鑻 $x_i = x_j$ 涓 $y_i \lt y_j$ 锛屽垯 $S_{ij} = -\infty$ 锛屽皢璇ョ偣瀵瑰瓙鎺掑湪搴忓垪鏈鍓嶏紱 +- 鑻 $x_i = x_j$ 涓 $y_i \gt y_j$ 锛屽垯 $S_{ij} = +\infty$ 锛屽皢璇ョ偣瀵瑰瓙鎺掑湪搴忓垪鏈鍚庛 ### 4. 浼拌鏂滅巼 From bc1a602e7ad826b180ef936dc7a377d3822f6ad0 Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:06:29 +0800 Subject: [PATCH 10/20] Update reg_pb.md --- docs/reg_pb.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/reg_pb.md b/docs/reg_pb.md index e85df35..d4b66d2 100644 --- a/docs/reg_pb.md +++ b/docs/reg_pb.md @@ -218,10 +218,9 @@ $$ 鎴窛 $a$ 鐨勭疆淇″尯闂翠负锛 $$ -\begin{cases} a_L = \text{median}\{y_i - b_Ux_i\} \\ + a_U = \text{median}\{y_i - b_Lx_i\} -\end{cases} $$ ## References From 4b4325d954638f124516e6d6baace434ea33a388 Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:06:55 +0800 Subject: [PATCH 11/20] Update reg_pb.md --- docs/reg_pb.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/reg_pb.md b/docs/reg_pb.md index d4b66d2..05e7c5b 100644 --- a/docs/reg_pb.md +++ b/docs/reg_pb.md @@ -218,8 +218,10 @@ $$ 鎴窛 $a$ 鐨勭疆淇″尯闂翠负锛 $$ -a_L = \text{median}\{y_i - b_Ux_i\} \\ +a_L = \text{median}\{y_i - b_Ux_i\} +$$ +$$ a_U = \text{median}\{y_i - b_Lx_i\} $$ From 7d402abcf629d358de42e5d4923d702baf48950f Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:08:07 +0800 Subject: [PATCH 12/20] Update reg_pb.md --- docs/reg_pb.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reg_pb.md b/docs/reg_pb.md index 05e7c5b..c55eabe 100644 --- a/docs/reg_pb.md +++ b/docs/reg_pb.md @@ -212,13 +212,13 @@ $$ 鍋囪姣忎釜鐐归兘鑳借惤鍦ㄧ嚎 $y = a + bx$ 涓婏紝杩涜屽姣忎釜鐐癸紝閮借兘璁$畻涓涓埅璺 $a_i = y_i - bx_i$ 锛屾墍鏈 $a_i$ 浠庡皬鍒板ぇ鎺掑簭锛屽彇涓綅鏁帮紝鍗冲彲寰楀埌鎴窛 $a$ 鐨勪及璁″硷細 $$ -a = \text{median}\{y_i - bx_i\} +a = \text{median}\left\{y_i - bx_i\right\} $$ 鎴窛 $a$ 鐨勭疆淇″尯闂翠负锛 $$ -a_L = \text{median}\{y_i - b_Ux_i\} +a_L = \text{median}\left{y_i - b_Ux_i\right} $$ $$ From fc897353ebc46a44f144e9bc32a1e1cc53ba15a7 Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:09:13 +0800 Subject: [PATCH 13/20] Update reg_pb.md --- docs/reg_pb.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reg_pb.md b/docs/reg_pb.md index c55eabe..f8a34cc 100644 --- a/docs/reg_pb.md +++ b/docs/reg_pb.md @@ -218,7 +218,7 @@ $$ 鎴窛 $a$ 鐨勭疆淇″尯闂翠负锛 $$ -a_L = \text{median}\left{y_i - b_Ux_i\right} +a_L = \text{median}\left\{y_i - b_Ux_i\right\} $$ $$ From c05457bb0b239c326962be567b2fa3c7dd679b08 Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:11:54 +0800 Subject: [PATCH 14/20] Update reg_pb.md --- docs/reg_pb.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reg_pb.md b/docs/reg_pb.md index f8a34cc..6580ace 100644 --- a/docs/reg_pb.md +++ b/docs/reg_pb.md @@ -212,7 +212,7 @@ $$ 鍋囪姣忎釜鐐归兘鑳借惤鍦ㄧ嚎 $y = a + bx$ 涓婏紝杩涜屽姣忎釜鐐癸紝閮借兘璁$畻涓涓埅璺 $a_i = y_i - bx_i$ 锛屾墍鏈 $a_i$ 浠庡皬鍒板ぇ鎺掑簭锛屽彇涓綅鏁帮紝鍗冲彲寰楀埌鎴窛 $a$ 鐨勪及璁″硷細 $$ -a = \text{median}\left\{y_i - bx_i\right\} +a = \mathrm{median}\left \{y_i - bx_i\right \} $$ 鎴窛 $a$ 鐨勭疆淇″尯闂翠负锛 From 8f1a29a14a211a2ac6641bf32a8a63ebe7c9f005 Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:13:29 +0800 Subject: [PATCH 15/20] Update reg_pb.md --- docs/reg_pb.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reg_pb.md b/docs/reg_pb.md index 6580ace..e48f1fe 100644 --- a/docs/reg_pb.md +++ b/docs/reg_pb.md @@ -212,7 +212,7 @@ $$ 鍋囪姣忎釜鐐归兘鑳借惤鍦ㄧ嚎 $y = a + bx$ 涓婏紝杩涜屽姣忎釜鐐癸紝閮借兘璁$畻涓涓埅璺 $a_i = y_i - bx_i$ 锛屾墍鏈 $a_i$ 浠庡皬鍒板ぇ鎺掑簭锛屽彇涓綅鏁帮紝鍗冲彲寰楀埌鎴窛 $a$ 鐨勪及璁″硷細 $$ -a = \mathrm{median}\left \{y_i - bx_i\right \} +a = \text{median} \lbrace y_i - bx_i \rbrace $$ 鎴窛 $a$ 鐨勭疆淇″尯闂翠负锛 From c87e6ea3359773a750db9d9a02d67cf320aceaf6 Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:14:16 +0800 Subject: [PATCH 16/20] Update reg_pb.md --- docs/reg_pb.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/reg_pb.md b/docs/reg_pb.md index e48f1fe..fde5750 100644 --- a/docs/reg_pb.md +++ b/docs/reg_pb.md @@ -218,11 +218,8 @@ $$ 鎴窛 $a$ 鐨勭疆淇″尯闂翠负锛 $$ -a_L = \text{median}\left\{y_i - b_Ux_i\right\} -$$ - -$$ -a_U = \text{median}\{y_i - b_Lx_i\} +a_L = \text{median} \lbrace y_i - b_Ux_i \rbrace \\ +a_U = \text{median} \lbrace y_i - b_Lx_i \rbrace $$ ## References From 60fdaa98f63147bd6d89c7f2e0dedc3ab851f9fd Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:15:17 +0800 Subject: [PATCH 17/20] Update reg_pb.md --- docs/reg_pb.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/reg_pb.md b/docs/reg_pb.md index fde5750..d2737eb 100644 --- a/docs/reg_pb.md +++ b/docs/reg_pb.md @@ -219,6 +219,7 @@ $$ $$ a_L = \text{median} \lbrace y_i - b_Ux_i \rbrace \\ + a_U = \text{median} \lbrace y_i - b_Lx_i \rbrace $$ From 5a795a75d4d75b598cb438741e2f1eca47f2d19f Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:15:42 +0800 Subject: [PATCH 18/20] Update reg_pb.md --- docs/reg_pb.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/reg_pb.md b/docs/reg_pb.md index d2737eb..541b2d6 100644 --- a/docs/reg_pb.md +++ b/docs/reg_pb.md @@ -218,8 +218,10 @@ $$ 鎴窛 $a$ 鐨勭疆淇″尯闂翠负锛 $$ -a_L = \text{median} \lbrace y_i - b_Ux_i \rbrace \\ +a_L = \text{median} \lbrace y_i - b_Ux_i \rbrace +$$ +$$ a_U = \text{median} \lbrace y_i - b_Lx_i \rbrace $$ From 99268ff0499db14425896d024855931c64d05248 Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:18:54 +0800 Subject: [PATCH 19/20] Update reg_pb.md --- docs/reg_pb.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reg_pb.md b/docs/reg_pb.md index 541b2d6..2a58da2 100644 --- a/docs/reg_pb.md +++ b/docs/reg_pb.md @@ -180,8 +180,8 @@ $$ $$ b = \begin{cases} -S_{\left(\frac{M + 1}{2} + K\right)}, & \text{if } M \text{ is odd} \\ -\frac{1}{2} \cdot \left( S_{\left(\frac{M}{2} + K\right)} + S_{\left(\frac{M}{2} + 1 + K\right)}\right), & \text{if } M \text{ is even} \\ +S_{\left(\frac{M + 1}{2} + K\right)} &,\text{ if } M \text{ is odd} \\ +\frac{1}{2} \cdot \left( S_{\left(\frac{M}{2} + K\right)} + S_{\left(\frac{M}{2} + 1 + K\right)}\right) &,\text{ if } M \text{ is even} \\ \end{cases} $$ From bf239cd7b75747636d2142d6bfb31a463c73ab70 Mon Sep 17 00:00:00 2001 From: Firefly <45487685+Snoopy1866@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:21:21 +0800 Subject: [PATCH 20/20] Update reg_pb.md --- docs/reg_pb.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/reg_pb.md b/docs/reg_pb.md index 2a58da2..e6b6ccf 100644 --- a/docs/reg_pb.md +++ b/docs/reg_pb.md @@ -202,7 +202,11 @@ $$ $b$ 鐨勭疆淇″尯闂翠负锛 $$ -S_{(M_1 + K)} \le b \le S_{(M_2 + K)} +b_L = S_{(M_1 + K)} +$$ + +$$ +b_U = S_{(M_2 + K)} $$ ### 6. 浼拌鎴窛鍙婂叾缃俊鍖洪棿