distrib 核心库中使用 cdf_binomial 的最大错误?

问题描述 投票:0回答:1

我对 maxima 很陌生,几天前我通过

brew
在 MacOS ARM 上安装了它。因此,我不知道我是否发现了错误或功能,或者我正在做一些愚蠢的事情。以下示例显示了我收到的意外错误:

$ maxima
Maxima 5.46.0 https://maxima.sourceforge.io
using Lisp SBCL 2.3.3
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) load ("distrib"); 
(%o1) /opt/homebrew/Cellar/maxima/5.46.0_11/share/maxima/5.46.0/share/distrib/\
distrib.mac
(%i2) cdf_binomial(4,4,p);
(%o2)                                  1
(%i3) subst( [S=3], cdf_binomial(S,4,p)); 
                                     3    2
(%o3)                      (1 - p) (p  + p  + p + 1)
(%i4) subst( [S=4], cdf_binomial(S,4,p));

beta_incomplete: beta_incomplete(0,5,1-p) is undefined.
 -- an error. To debug this try: debugmode(true);
(%i5) 

我在这里做错了什么吗? (PS:我的实际用途是将 p 积分到 1,这也会触发此问题。)是否有标准的解决方法?

建议赞赏。

maxima binomial-cdf
1个回答
0
投票

您看到的错误实际上是未评估条件表达式处理方式的微妙结果。 (一个未评估的条件示例由

cdf_binomial(S, 4, p)
返回。)一个更简单的错误示例(我将创建一个错误报告)是
'(if 0 > 0 then 0/0 else inf)
,即使
0 > 0
为假,它也会遇到除数为 0 的错误。

作为解决方法,请尝试

ev(myexpr, S = 4)
,其中
myexpr
被赋予
cdf_binomial(S, 4, p)
返回的值。

如果

ev
具有指定值,则无需通过
S
绕行 - 在这种情况下,
cdf_binomial
返回一个或另一个案例,并且不返回未评估的条件。当
cdf_binomial
被调用而
S
没有分配值时,需要特殊处理,因此
cdf_binomial
不知道要采用哪个分支,因此返回未评估的条件。

© www.soinside.com 2019 - 2024. All rights reserved.