BrownForsytheTest[data]
检验 data 的方差是否为1.
BrownForsytheTest[{data1,data2,…}]
检验 data1 和 data2 的方差是否相等.
BrownForsytheTest[dspec,
]
检验一个离散量数和
的关系.
BrownForsytheTest[dspec,
,"property"]
返回 "property" 的值.
BrownForsytheTest
BrownForsytheTest[data]
检验 data 的方差是否为1.
BrownForsytheTest[{data1,data2,…}]
检验 data1 和 data2 的方差是否相等.
BrownForsytheTest[dspec,
]
检验一个离散量数和
的关系.
BrownForsytheTest[dspec,
,"property"]
返回 "property" 的值.
更多信息和选项
- BrownForsytheTest 检验零假设
与备择假设
: -


data 

{data1,data2} 

{data1,data2,…} 
不全相等 - 其中 σi2 为 datai 的总体方差.
- 默认情况下,返回一个概率值或者
值. - 一个较小的
值表明
不可能为真. - 在 dspec 中,data 必须是单变量 {x1,x2,…}.
- 参数
可以是任意正实数.
在未指定的情况下为1,在 dspec 中组数大于 2 的情况下则被忽略. - BrownForsytheTest 假设数据服从正态分布.
- BrownForsytheTest 比起 LeveneTest 对正态性假设较不敏感.
- BrownForsytheTest[data,
,"HypothesisTestData"] 返回一个 HypothesisTestData 对象 htd , 可以使用 htd["property"] 的形式提取额外检验结果和属性. - BrownForsytheTest[data,
,"property"] 可用于直接给出 "property" 的值. - 与检验结果报告相关的属性包括:
-
"DegreesOfFreedom" 检验中所用的自由度 "PValue"
值列表"PValueTable"
值组成的格式化表格"ShortTestConclusion" 检验结论的简短描述 "TestConclusion" 检验结论的描述 "TestData" 检验统计量和
值对组成的列表"TestDataTable"
值和检验统计量组成的格式化表格"TestStatistic" 检验统计量组成的列表 "TestStatisticTable" 检验统计量的格式化的表格 - 当样本数
给定,BrownForsytheTest 等价于 FisherRatioTest. - 对于
-样本的情况,BrownForsytheTest 是 LeveneTest 的修正,用函数
替代 Abs[dataij-Mean[dataij]] 中的 Mean. 函数 fn 通常为选定为 Median,但如果数据为重尾型,则使用TrimmedMean[#,1/10]&. - 可以使用下列选项:
-
AlternativeHypothesis "Unequal" 备择假设的不等性 SignificanceLevel 0.05 用于诊断和报告的分界点 VerifyTestAssumptions Automatic 设置要运行哪个诊断检验 - 对于 BrownForsytheTest,选择一个临界值
,使得只有当
时,拒绝
. 用于 "TestConclusion" 和 "ShortTestConclusion" 属性的
值由 SignificanceLevel 选项控制. 值
也用于包含正态性和对称性的假设诊断检验. 默认情况下,
设为 0.05. - 在 BrownForsytheTest 中 VerifyTestAssumptions 的已命名设置包括:
-
"Normality" 验证所有数据是否服从正态分布
范例
打开所有单元 关闭所有单元基本范例 (2)
data = RandomVariate[NormalDistribution[], {2, 100}];BrownForsytheTest[data]创建一个 HypothesisTestData 对象,用于进一步的属性提取:
ℋ = BrownForsytheTest[data, Automatic, "HypothesisTestData"]ℋ["Properties"]SeedRandom["test"];
data1 = RandomVariate[NormalDistribution[0, 1], 100];
data2 = RandomVariate[NormalDistribution[0, 2.5], 250];BrownForsytheTest[{data1, data2}, 1 / 4, "TestDataTable"]Variance[data1] / Variance[data2]BrownForsytheTest[{data1, data2}, 1 / 4, AlternativeHypothesis -> "Less"]范围 (10)
检验 (8)
SeedRandom[1];
data1 = RandomVariate[NormalDistribution[], 500];
data2 = RandomVariate[NormalDistribution[1, .3], 500];BrownForsytheTest[data1]BrownForsytheTest[data2]SeedRandom["val"];data1 = RandomVariate[NormalDistribution[0, 2], 10^4];
data2 = RandomVariate[NormalDistribution[0, 2.1], 10^4];BrownForsytheTest[data1, 2^2]BrownForsytheTest[data2, 2^2]SeedRandom["2"];data1 = RandomVariate[NormalDistribution[0, 3], 500];
data2 = RandomVariate[NormalDistribution[1, 3], 500];BrownForsytheTest[{data1, data2}]sample = Table[Quiet@BrownForsytheTest[{RandomVariate[NormalDistribution[0, 3], 100], RandomVariate[NormalDistribution[1, 3], 100]}], {5 10 ^ 3}];Histogram[sample, Automatic, PDF]data3 = RandomVariate[NormalDistribution[10, 1], 350];BrownForsytheTest[{data1, data3}]SeedRandom["ratio"];data1 = RandomVariate[NormalDistribution[0, 2], 500];
data2 = RandomVariate[NormalDistribution[0, 1], 500];Subscript[σ, 0] = 4;BrownForsytheTest[{data1, data2}, Subscript[σ, 0]]BrownForsytheTest[{data2, data1}, 1 / Subscript[σ, 0]]BrownForsytheTest[{data2, data1}, Subscript[σ, 0]]SeedRandom["3"];data1 = RandomVariate[NormalDistribution[10, 1], 500];
data2 = RandomVariate[NormalDistribution[0, 1], 200];
data3 = RandomVariate[NormalDistribution[-3, 1], 400];BrownForsytheTest[{data1, data2, data3}]创建一个 HypothesisTestData 对象,以进行重复属性提取:
SeedRandom["prop"];data = RandomVariate[NormalDistribution[], {2, 10^4}];ℋ = BrownForsytheTest[data, 1, "HypothesisTestData"];ℋ["Properties"]从一个 HypothesisTestData 提取某些属性:
SeedRandom["obj"];data = RandomVariate[NormalDistribution[], {2, 10^4}];ℋ = BrownForsytheTest[data, 1, "HypothesisTestData"];ℋ["PValue"]ℋ["TestStatistic"]ℋ["DegreesOfFreedom"]SeedRandom["m"];data = RandomVariate[NormalDistribution[], {2, 100}];ℋ = BrownForsytheTest[data, 1, "HypothesisTestData"];ℋ["PValue", "TestStatistic", "DegreesOfFreedom"]报告 (2)
SeedRandom["tab"];data = RandomVariate[NormalDistribution[], {2, 10^3}];ℋ = BrownForsytheTest[data, 1, "HypothesisTestData"];ℋ["TestDataTable"]ℋ["TestData"]SeedRandom["tab"];data = RandomVariate[NormalDistribution[], {3, 10^4}];ℋ = BrownForsytheTest[data, 1, "HypothesisTestData"];ℋ["PValueTable"]ℋ["PValue"]ℋ["TestStatisticTable"]ℋ["TestStatistic"]选项 (8)
AlternativeHypothesis (3)
SeedRandom["alt"];data = RandomVariate[NormalDistribution[], 100];BrownForsytheTest[data, 1, AlternativeHypothesis -> "Unequal"]BrownForsytheTest[data, 1, AlternativeHypothesis -> Automatic]SeedRandom["alt"];data = RandomVariate[NormalDistribution[0, 1.25], 100];BrownForsytheTest[data, Automatic, AlternativeHypothesis -> "Unequal"]BrownForsytheTest[data, Automatic, AlternativeHypothesis -> "Less"]BrownForsytheTest[data, Automatic, AlternativeHypothesis -> "Greater"]SeedRandom["null"];
data1 = RandomVariate[NormalDistribution[0, .9], 100];
data2 = RandomVariate[NormalDistribution[0, 1], 100];Variance[data1] / Variance[data2]BrownForsytheTest[{data1, data2}, 1, AlternativeHypothesis -> "Less"]BrownForsytheTest[{data1, data2}, 1.5, AlternativeHypothesis -> "Less"]SignificanceLevel (2)
data = BlockRandom[SeedRandom[5];RandomVariate[StudentTDistribution[3], 50]];BrownForsytheTest[data, 1, SignificanceLevel -> .005]BrownForsytheTest[data, 1, SignificanceLevel -> Automatic]对 "TestConclusion" 和 "ShortTestConclusion" 也使用显著性水平:
data = BlockRandom[SeedRandom[1];RandomVariate[NormalDistribution[0, 1], 100]];ℋ1 = BrownForsytheTest[data, 1.5, "HypothesisTestData", SignificanceLevel -> .05];ℋ2 = BrownForsytheTest[data, 1.5, "HypothesisTestData", SignificanceLevel -> .01];ℋ1["TestConclusion"]//TraditionalFormℋ2["TestConclusion"]//TraditionalFormℋ1["ShortTestConclusion"]ℋ2["ShortTestConclusion"]VerifyTestAssumptions (3)
SeedRandom["ver"];data1 = RandomVariate[StudentTDistribution[3], 1000];
data2 = RandomVariate[NormalDistribution[0, Sqrt[3]], 1000];BrownForsytheTest[{data1, data2}, 1 / 4, VerifyTestAssumptions -> All]BrownForsytheTest[{data1, data2}, 1 / 4, VerifyTestAssumptions -> None]SeedRandom["ver"];data1 = RandomVariate[StudentTDistribution[2], 1000];
data2 = RandomVariate[NormalDistribution[0, Sqrt[3]], 1000];BrownForsytheTest[{data1, data2}, 1 / 4, VerifyTestAssumptions -> "Normality"]将假定值设为 True:
BrownForsytheTest[{data1, data2}, 1 / 4, VerifyTestAssumptions -> "Normality" -> True]SeedRandom["test"];data = RandomVariate[NormalDistribution[], {1000, 100}];AbsoluteTiming[T = Quiet@BrownForsytheTest[#, Automatic, "TestStatistic"]& /@ data;]AbsoluteTiming[T2 = Quiet@BrownForsytheTest[#, Automatic, "TestStatistic", VerifyTestAssumptions -> None]& /@ data;]SmoothHistogram[{T, T2}]应用 (1)
使用 Brown–Forsythe 检验判断对于等均值
-检验是否需要近似的自由度:
data1 = {-0.509, 2.25, -0.553, 1.234, 0.527, 0.319, 1.315, 1.024, 0.212, 0.835, 0.215, 0.652, 0.705, 0.683, -0.804};data2 = {-0.714, 4.559, 1.546, 2.819, -0.814, -4.146, 0.409, -3.241, -3.987, -2.739, 0.254, -4.887, -7.827, 0.424, -0.095};L[x_] := Length[x];v[x_] := Variance[x]ttest[𝒹1_, 𝒹2_, μ0_, df_] := With[{t = (Mean[𝒹1] - Mean[𝒹2] - μ0/Sqrt[(v[𝒹1]/L[𝒹1]) + (v[𝒹2]/L[𝒹2])])}, {"T" -> t, "p" -> 2 Min[SurvivalFunction[StudentTDistribution[df], t], CDF[StudentTDistribution[df], t]], "df" -> df}]如果两个样本具有相等的方差,则可以使用下列自由度;否则,需要一个 Satterthwaite 近似:
evDF[𝒹1_, 𝒹2_] := L[𝒹1] + L[𝒹2] - 2SatterthwaiteDF[𝒹1_, 𝒹2_] := (((v[𝒹1]/L[𝒹1]) + (v[𝒹2]/L[𝒹2]))^2/((v[𝒹1]/L[𝒹1]))^2 / (L[𝒹1] - 1) + ((v[𝒹2]/L[𝒹2]))^2 / (L[𝒹2] - 1))BrownForsytheTest[{data1, data2}, 1, "TestDataTable"]ttest[data1, data2, 0, evDF[data1, data2]]ttest[data1, data2, 0, SatterthwaiteDF[data1, data2]]TTest 自动使用 Satterthwaite 近似:
TTest[{data1, data2}, 0, {"TestDataTable", "DegreesOfFreedom"}]属性和关系 (8)
当给定单个数据集时,Brown-Forsythe 检验等价于 FisherRatioTest:
SeedRandom["e"];data = RandomVariate[NormalDistribution[], 100];BrownForsytheTest[data]FisherRatioTest[data]给定长度为
的单个数据集,在
下,检验统计量服从 ChiSquareDistribution[n-1]:
SeedRandom["chi"];data = RandomVariate[NormalDistribution[], {1000, 100}];T = BrownForsytheTest[#, Automatic, "TestStatistic", VerifyTestAssumptions -> None]& /@ data;Show[SmoothHistogram[T], Plot[PDF[ChiSquareDistribution[99], x], {x, 50, 160}, PlotStyle -> Orange]]EstimatedDistribution[T, ChiSquareDistribution[df]]DistributionFitTest[T, ChiSquareDistribution[99]]给定长度为
和
的两个数据集,在
下,检验统计量服从 FRatioDistribution[1,n+m-2]:
n = 100;
m = 75;
SeedRandom["F"];
data1 = RandomVariate[NormalDistribution[], {1000, n}];
data2 = RandomVariate[NormalDistribution[], {1000, m}];T = MapThread[BrownForsytheTest[{#1, #2}, Automatic, "TestStatistic", VerifyTestAssumptions -> None]&, {data1, data2}];Show[Histogram[T, {0.2}, "PDF"], Plot[PDF[FRatioDistribution[1, n + m - 2], x], {x, 0, 8}, PlotRange -> {0, 1}]]DistributionFitTest[T, FRatioDistribution[1, n + m - 2], "TestConclusion"]给定两个数据集,Brown–Forsythe 检验比起 FisherRatioTest 对正态性假设较为不敏感:
SeedRandom["F"];data1 = RandomVariate[LaplaceDistribution[1, 2], {1000, 100}];
data2 = RandomVariate[LaplaceDistribution[1, 2], {1000, 75}];fisher = MapThread[FisherRatioTest[{#1, #2}, VerifyTestAssumptions -> None]&, {data1, data2}];levene = MapThread[BrownForsytheTest[{#1, #2}, VerifyTestAssumptions -> None]&, {data1, data2}];Fisher-Ratio 检验倾向于低估
值,因而产生更多的第一类错误:
Histogram[{fisher, levene}, Automatic, "PDF"]Subscript[n, 1] = 100;Subscript[n, 2] = 75;Subscript[σ, 0] = 2;SeedRandom["2"];data1 = RandomVariate[NormalDistribution[0, Subscript[σ, 0]], Subscript[n, 1]];
data2 = RandomVariate[NormalDistribution[0, 1], Subscript[n, 2]];Subscript[n, t] = Subscript[n, 1] + Subscript[n, 2];bfor[d1_, d2_, f_] := Block[{μZ1, μZ2, z1, z2, μZZ},
z1 = Abs@Standardize[d1, f, 1&];
z2 = Subscript[σ, 0]Abs@Standardize[d2, f, 1&];
μZ1 = Mean[z1];μZ2 = Mean[z2];
μZZ = (Subscript[n, 1] μZ1 + Subscript[n, 2] μZ2/Subscript[n, t]);
(Subscript[n, t] - 2)(Subscript[n, 1](μZ1 - μZZ)^2 + Subscript[n, 2](μZ2 - μZZ)^2/(z1 - μZ1).(z1 - μZ1) + (z2 - μZ2).(z2 - μZ2))]通常,Median 作为标准化函数使用:
bfor[data1, data2, Median]BrownForsytheTest[{data1, data2}, Subscript[σ, 0] ^ 2, "TestStatistic"]对重尾数据,使用 10% TrimmedMean:
data3 = RandomVariate[CauchyDistribution[0, Subscript[σ, 0]], Subscript[n, 1]];
data4 = RandomVariate[CauchyDistribution[0, 1], Subscript[n, 2]];bfor[data3, data4, TrimmedMean[#, .1]&]BrownForsytheTest[{data3, data4}, Subscript[σ, 0] ^ 2, "TestStatistic", VerifyTestAssumptions -> None]LeveneTest 是等价的,但是总是使用 Mean 来标准化:
bfor[data1, data2, Mean]LeveneTest[{data1, data2}, Subscript[σ, 0] ^ 2, "TestStatistic"]Subscript[n, 1] = 1000;Subscript[n, 2] = 750;Subscript[n, 3] = 1500;SeedRandom["3"];data1 = RandomVariate[NormalDistribution[-4, 3], Subscript[n, 1]];
data2 = RandomVariate[NormalDistribution[1, 3], Subscript[n, 2]];
data3 = RandomVariate[NormalDistribution[5, 3], Subscript[n, 3]];Subscript[n, t] = Subscript[n, 1] + Subscript[n, 2] + Subscript[n, 3];bfor3[d1_, d2_, d3_] := Block[{μZ1, μZ2, μZ3, z1, z2, z3, μZZ},
z1 = Abs[d1 - Median[d1]];
z2 = Abs[d2 - Median[d2]];
z3 = Abs[d3 - Median[d3]];
μZ1 = Mean[z1];μZ2 = Mean[z2];μZ3 = Mean[z3];
μZZ = (Subscript[n, 1]μZ1 + Subscript[n, 2]μZ2 + Subscript[n, 3]μZ3/Subscript[n, t]);
((Subscript[n, t] - 3)/2)(Subscript[n, 1](μZ1 - μZZ)^2 + Subscript[n, 2](μZ2 - μZZ)^2 + Subscript[n, 3](μZ3 - μZZ)^2/Total[(z1 - μZ1) ^ 2] + Total[(z2 - μZ2) ^ 2] + Total[(z3 - μZ3) ^ 2])]bfor3[data1, data2, data3]BrownForsytheTest[{data1, data2, data3}, 1, "TestStatistic"]Brown–Forsythe 检验仅当输入为 TimeSeries 时适用于值:
ts = TemporalData[TimeSeries, {{{1.224578634529677, 0.47929635789978015, 0.6572781300178168,
0.21496048742669355, 0.7299608014554928, -0.2495111111278263, -1.3286551762002712,
0.552725018274874, 0.19272112205837066, 1.1809144012420882, -1.1671 ... 40938613662046, 1.052394590214582, 0.9345044123980388, 0.38537803109557855,
-0.48660931166089394, -0.71203560340161}}, {{0, 100, 1}}, 1, {"Continuous", 1},
{"Discrete", 1}, 1, {ValueDimensions -> 1, ResamplingMethod -> None}}, False, 10.1];BrownForsytheTest[ts]BrownForsytheTest[ts["Values"]]当输入为 TemporalData 时,Brown–Forsythe 检验适用于所有值在一起:
td = TemporalData[Automatic, {{{-0.25275046867718637, -0.7175779198306353, -1.9370139837317764,
0.006665621735740701, -0.3730807122324292, 0.6740106823161018, 0.8562214990564344,
0.955785083955732, 1.7020898014886303, 1.8523009430646802, 0.244 ... 3951759101545, -1.1611722313627828, 1.1602446901533021,
1.1052173095128992, 1.1089143920161917, -0.13837156328402}}, {{0, 100, 1}}, 2,
{"Continuous", 2}, {"Discrete", 1}, 1, {ValueDimensions -> 1, ResamplingMethod -> None}}, False,
10.1];BrownForsytheTest[td]data = td["ValueList"]//Flatten;
BrownForsytheTest[data]{data1, data2} = td["ValueList"];BrownForsytheTest[{data1, data2}]可能存在的问题 (3)
Brown–Forsythe 检验假定数据从 NormalDistribution 中抽取:
SeedRandom["n"];data = RandomVariate[LaplaceDistribution[1, 2], {2, 100}];BrownForsytheTest[data, 1, "TestDataTable"]对非正态数据,使用 ConoverTest 或者 SiegelTukeyTest:
ConoverTest[data, 1, "TestDataTable"]SiegelTukeyTest[data, 1, "TestDataTable"]在组数大于 2 时,Brown–Forsythe 检验忽略参数
:
SeedRandom["1"];data = RandomVariate[NormalDistribution[1, 2], {4, 100}];Length[data]BrownForsytheTest[data, 2, "TestDataTable"]当有两组以上数据时,Brown–Forsythe 检验仅允许对备择假设的双边检验:
SeedRandom["alt"];data = RandomVariate[NormalDistribution[1, 2], {4, 100}];BrownForsytheTest[data, 1, AlternativeHypothesis -> "Unequal"]BrownForsytheTest[data, 1, AlternativeHypothesis -> "Greater"]BrownForsytheTest[data, 1, AlternativeHypothesis -> "Less"]巧妙范例 (1)
SeedRandom["neat"];data = RandomVariate[NormalDistribution[], {250, 100}];T1 = BrownForsytheTest[#, 1, "TestStatistic", VerifyTestAssumptions -> None]& /@ data;T2 = BrownForsytheTest[#, 3, "TestStatistic", VerifyTestAssumptions -> None]& /@ data;SmoothHistogram[{T1, T2}, Filling -> Axis, PlotLegends -> {"SubscriptBox[H, 0] is True", "SubscriptBox[H, 0] is False"}, PlotStyle -> Thick]相关指南
-
▪
- 假设检验
文本
Wolfram Research (2010),BrownForsytheTest,Wolfram 语言函数,https://reference.wolfram.com/language/ref/BrownForsytheTest.html (更新于 2017 年).
CMS
Wolfram 语言. 2010. "BrownForsytheTest." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2017. https://reference.wolfram.com/language/ref/BrownForsytheTest.html.
APA
Wolfram 语言. (2010). BrownForsytheTest. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/BrownForsytheTest.html 年
BibTeX
@misc{reference.wolfram_2026_brownforsythetest, author="Wolfram Research", title="{BrownForsytheTest}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/BrownForsytheTest.html}", note=[Accessed: 16-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_brownforsythetest, organization={Wolfram Research}, title={BrownForsytheTest}, year={2017}, url={https://reference.wolfram.com/language/ref/BrownForsytheTest.html}, note=[Accessed: 16-August-2026]}