求解包含卡方概率的方程
solving equation containing chi-square probability
我想解这个方程并在 Matlab 中找到 'u'。
对于这个等式的左边,我们有 chi2cdf(u, 2*Nr, 'upper')
但我无法使用它并出现错误。
syms x positive
eqn = chi2cdf (x,2,'upper');
我收到了这个错误:
Error using symengine
cannot prove 'x<0' literally. to test the statement mathematically, use isAlways.
我该如何解决这个问题?
- 改用函数句柄,
x
的符号仅重要在评估时
函数
- 评估时只需将范围设置为
[0, inf]
,sign 隐式设置为 positive
- 用
fzero()
解方程为零
fzero()
不允许无限边界,inf
可以替换为 exp(709)
- Why
exp(709)
?: exp(709) = finite
while exp(710) = infinite
代码如下
% Assuming L, M
L = 0.1;
M = 2;
% Equation
f =@(x) chi2cdf (x,2,'upper')-L/M;
% solve
sol = fzero(f, [0, exp(709)]);
解决方案
sol = 5.9915
我想解这个方程并在 Matlab 中找到 'u'。
对于这个等式的左边,我们有 chi2cdf(u, 2*Nr, 'upper')
但我无法使用它并出现错误。
syms x positive
eqn = chi2cdf (x,2,'upper');
我收到了这个错误:
Error using symengine
cannot prove 'x<0' literally. to test the statement mathematically, use isAlways.
我该如何解决这个问题?
- 改用函数句柄,
x
的符号仅重要在评估时 函数 - 评估时只需将范围设置为
[0, inf]
,sign 隐式设置为 positive - 用
fzero()
解方程为零 fzero()
不允许无限边界,inf
可以替换为exp(709)
- Why
exp(709)
?:exp(709) = finite
whileexp(710) = infinite
代码如下
% Assuming L, M
L = 0.1;
M = 2;
% Equation
f =@(x) chi2cdf (x,2,'upper')-L/M;
% solve
sol = fzero(f, [0, exp(709)]);
解决方案
sol = 5.9915