【问题标题】:Error in R: roundoff error is detected in the extrapolation tableR中的错误:在外推表中检测到舍入错误
【发布时间】:2022-08-03 16:05:38
【问题描述】:

我正在尝试使用 R 中的积分函数计算消费者剩余。

PID = 2040;
integrand <- function(x) {320000*x^(-0.1)} 
integrate(integrand, lower = PID, upper = Inf,  
          rel.tol=.Machine$double.eps^.05 )$value

然后错误显示“在外推表中检测到舍入错误”。 如果我将指数更改为 -1,则不会显示错误并且它会发出一个值。 如何通过保持指数值 -0.1 来修复错误?

非常感谢您提前提供的帮助。

  • 欢迎来到 SO。不是直接的答案,但this post 建议使用 cubature 包给你更多成功的机会。
  • 在积分之前,您需要确保积分收敛。你确定吗?

标签: r integrate


【解决方案1】:

尝试这个,

PID = 2040;
integrand <- function(x) {320000*x^(-0.1)} 
integrate(integrand, lower = PID, upper = .Machine$double.xmax, rel.tol=.Machine$double.eps^.05 )$value

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-03
    • 1970-01-01
    • 1970-01-01
    • 2020-09-04
    • 2017-01-12
    • 2010-10-31
    • 1970-01-01
    相关资源
    最近更新 更多