Weights
不同拟合函数和其它函数的选项,指定与数据元素相关的权重.
范例
打开所有单元 关闭所有单元基本范例 (1)
LinearModelFit[Range[10] ^ 2, x, x]//NormalLinearModelFit[Range[10] ^ 2, x, x, Weights -> 1 / Range[10]]//NormalLinearModelFit[Range[10] ^ 2, x, x, Weights -> (Sqrt[#]&)]//NormalLinearModelFit[Range[10] ^ 2, x, x, Weights -> (Sqrt[#2]&)]//Normal范围 (2)
data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}};NonlinearModelFit[data, Log[a + b x ^ 2], {a, b}, x]//Normal(nlm = NonlinearModelFit[data, Log[a + b x ^ 2], {a, b}, x, Weights -> {1, (1/2), (1/3), (1/4)}])//Normaldata = {{0, 1}, {1, 0}, {3, 2}, {5, 10}};GeneralizedLinearModelFit[data, x, x, ExponentialFamily -> "Poisson"]//NormalGeneralizedLinearModelFit[data, x, x, ExponentialFamily -> "Poisson", Weights -> {1, 2, 3, 4}]//NormalLogitModelFit[{.01, .3, .5, .7, .9}, x, x]//NormalLogitModelFit[{.01, .3, .5, .7, .9}, x, x, Weights -> (1 / Sqrt[#]&)]//NormalProbitModelFit[{.01, .3, .5, .7, .9}, x, x]//NormalProbitModelFit[{.01, .3, .5, .7, .9}, x, x, Weights -> (1 / Sqrt[#]&)]//Normaldata = {{2.8, 1.8, 4.5}, {1.8, 2.2, 2.7}, {0.6, 4.6, 1.6}, {2.8, 4.1, 2.6}, {3., 0.1, 3.7}};LinearModelFit[data, {x, y}, {x, y}, Weights -> (Sqrt[#1 ^ 2 + #2 ^ 2]&)]//NormalLinearModelFit[data, {x, y}, {x, y}]//NormalLinearModelFit[data, {x, y}, {x, y}, Weights -> (Log[#3]&)]//Normal应用 (1)
data = {{2.8, 1.8, 4.5}, {1.8, 2.2, 2.7}, {0.6, 4.6, 0.6}, {2.8, 4.1, 2.6}, {3., 0.1, 3.7}};Δys = {.1, .15, .12, .2, .08};nlm = NonlinearModelFit[data, a x Exp[b Sin[y]], {a, b}, {x, y}, Weights -> 1 / Δys ^ 2, VarianceEstimatorFunction -> (1&)]nlm["ParameterErrors"]nlm["ParameterErrors", VarianceEstimatorFunction -> Automatic]属性和关系 (2)
LinearModelFit[Range[10], x ^ 2, x, Weights -> Range[10]]//NormalLinearModelFit[Range[10], x ^ 2, x, Weights -> Range[10] / Total[Range[10]]]//Normaldata = RandomReal[10, {5, 2}];
wts = {1, 2, 3, 2, 1};LinearModelFit[data, {x, Sin[x]}, x, Weights -> wts]["BestFitParameters"]当考虑权重时,LeastSquares 给出相等的结果:
dm = DesignMatrix[data, {x, Sin[x]}, x];
resp = data[[All, -1]];
LeastSquares[Sqrt[wts]dm, Sqrt[wts]resp]文本
Wolfram Research (2008),Weights,Wolfram 语言函数,https://reference.wolfram.com/language/ref/Weights.html.
CMS
Wolfram 语言. 2008. "Weights." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/Weights.html.
APA
Wolfram 语言. (2008). Weights. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/Weights.html 年
BibTeX
@misc{reference.wolfram_2026_weights, author="Wolfram Research", title="{Weights}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/Weights.html}", note=[Accessed: 03-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_weights, organization={Wolfram Research}, title={Weights}, year={2008}, url={https://reference.wolfram.com/language/ref/Weights.html}, note=[Accessed: 03-September-2026]}