从 sfit 对象获取均值和标准差
Get mean and std from sfit object
加载完成后,预拟合曲面(sfit
)模型如下图所示。
问题:如何从 sfit 对象中获取 x/y 数据的精确 mean/std(而不是从输出中进行繁琐的复制)?
备注:
- 我可以通过调用其
coeffnames
/coeffvalues
API 来获取所有系数。但是,mean/std. 似乎没有类似的 API
- 当前无法访问sfit模型拟合的原始数据。所以the method依赖原始数据是不适用的。
查看sfit
class的来源,原来均值和标准差存储在private
属性中meanx
,meany
, stdx
, stdy
。这些都是 private
的事实使这项工作变得非常重要,但是 thanks to Yair Altman we know that 在 class 上调用 struct()
通常会揭示它的所有优点。
中稍作修改的示例
x = 3 - 6 * rand( 49, 1 );
y = 3 - 6 * rand( 49, 1 );
z = peaks( x, y );
sf = fit( [x, y], z, 'poly32', 'normalize', 'on');
这是我们看到的:
>> sf
Linear model Poly32:
sf(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 + p30*x^3 +
p21*x^2*y + p12*x*y^2
where x is normalized by mean -0.3736 and std 1.887
and where y is normalized by mean -0.04893 and std 1.644
Coefficients (with 95% confidence bounds):
p00 = 0.4227 (-0.3731, 1.218)
p10 = 1.764 (0.5627, 2.965)
p01 = 1.313 (0.7715, 1.855)
p20 = -0.1054 (-0.6496, 0.4389)
p11 = 0.4627 (0.03944, 0.8859)
p02 = 0.1898 (-0.2443, 0.6239)
p30 = -0.6345 (-1.247, -0.02209)
p21 = -0.8263 (-1.32, -0.3327)
p12 = -0.4908 (-1.011, 0.02911)
>> sf_struct=struct(sf)
Warning: Calling STRUCT on an object prevents the object from hiding its implementation details and should thus be avoided. Use DISP or
DISPLAY to see the visible public details of an object. See 'help struct' for more information.
sf_struct =
version: 2
fCoeffValues: {[0.4227] [1.7639] [1.3130] [-0.1054] [0.4627] [0.1898] [-0.6345] [-0.8263] [-0.4908]}
fProbValues: {1x0 cell}
sse: 59.5574
dfe: 40
rinv: [9x9 double]
activebounds: [9x1 logical]
meanx: -0.3736
meany: -0.0489
stdx: 1.8875
stdy: 1.6441
xlim: [-2.8236 2.8090]
ylim: [-2.7585 2.6763]
fType: 'poly32'
fTypename: 'Poly32'
fCategory: 'library'
defn: 'p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 + p30*x^3 + p21*x^2*y + p12*x*y^2'
fFeval: 1
expr: @polySurface
Adefn: {}
Aexpr: {}
linear: 1
derexpr: @polySurfaceDerivative
intexpr: []
args: [11x3 char]
isEmpty: 0
numArgs: 11
numCoeffs: 9
assignCoeff: [1x234 char]
assignData: ' x = FITTYPE_INPUTS_{10}; y = FITTYPE_INPUTS_{11};'
assignProb: ''
indep: [2x1 char]
depen: 'z'
coeff: [9x3 char]
prob: ''
fConstants: {[3] [2]}
fNonlinearcoeffs: []
fFitoptions: [1x1 curvefit.llsqoptions]
fStartpt: []
>> [sf_struct.meanx, sf_struct.meany, sf_struct.stdx, sf_struct.stdy]
ans =
-0.3736 -0.0489 1.8875 1.6441
至少在 R2012b 中以上内容有效。
加载完成后,预拟合曲面(sfit
)模型如下图所示。
问题:如何从 sfit 对象中获取 x/y 数据的精确 mean/std(而不是从输出中进行繁琐的复制)?
备注:
- 我可以通过调用其
coeffnames
/coeffvalues
API 来获取所有系数。但是,mean/std. 似乎没有类似的 API
- 当前无法访问sfit模型拟合的原始数据。所以the method依赖原始数据是不适用的。
查看sfit
class的来源,原来均值和标准差存储在private
属性中meanx
,meany
, stdx
, stdy
。这些都是 private
的事实使这项工作变得非常重要,但是 thanks to Yair Altman we know that 在 class 上调用 struct()
通常会揭示它的所有优点。
x = 3 - 6 * rand( 49, 1 );
y = 3 - 6 * rand( 49, 1 );
z = peaks( x, y );
sf = fit( [x, y], z, 'poly32', 'normalize', 'on');
这是我们看到的:
>> sf
Linear model Poly32:
sf(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 + p30*x^3 +
p21*x^2*y + p12*x*y^2
where x is normalized by mean -0.3736 and std 1.887
and where y is normalized by mean -0.04893 and std 1.644
Coefficients (with 95% confidence bounds):
p00 = 0.4227 (-0.3731, 1.218)
p10 = 1.764 (0.5627, 2.965)
p01 = 1.313 (0.7715, 1.855)
p20 = -0.1054 (-0.6496, 0.4389)
p11 = 0.4627 (0.03944, 0.8859)
p02 = 0.1898 (-0.2443, 0.6239)
p30 = -0.6345 (-1.247, -0.02209)
p21 = -0.8263 (-1.32, -0.3327)
p12 = -0.4908 (-1.011, 0.02911)
>> sf_struct=struct(sf)
Warning: Calling STRUCT on an object prevents the object from hiding its implementation details and should thus be avoided. Use DISP or
DISPLAY to see the visible public details of an object. See 'help struct' for more information.
sf_struct =
version: 2
fCoeffValues: {[0.4227] [1.7639] [1.3130] [-0.1054] [0.4627] [0.1898] [-0.6345] [-0.8263] [-0.4908]}
fProbValues: {1x0 cell}
sse: 59.5574
dfe: 40
rinv: [9x9 double]
activebounds: [9x1 logical]
meanx: -0.3736
meany: -0.0489
stdx: 1.8875
stdy: 1.6441
xlim: [-2.8236 2.8090]
ylim: [-2.7585 2.6763]
fType: 'poly32'
fTypename: 'Poly32'
fCategory: 'library'
defn: 'p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 + p30*x^3 + p21*x^2*y + p12*x*y^2'
fFeval: 1
expr: @polySurface
Adefn: {}
Aexpr: {}
linear: 1
derexpr: @polySurfaceDerivative
intexpr: []
args: [11x3 char]
isEmpty: 0
numArgs: 11
numCoeffs: 9
assignCoeff: [1x234 char]
assignData: ' x = FITTYPE_INPUTS_{10}; y = FITTYPE_INPUTS_{11};'
assignProb: ''
indep: [2x1 char]
depen: 'z'
coeff: [9x3 char]
prob: ''
fConstants: {[3] [2]}
fNonlinearcoeffs: []
fFitoptions: [1x1 curvefit.llsqoptions]
fStartpt: []
>> [sf_struct.meanx, sf_struct.meany, sf_struct.stdx, sf_struct.stdy]
ans =
-0.3736 -0.0489 1.8875 1.6441
至少在 R2012b 中以上内容有效。