gpt4 book ai didi

r - dnorm(x, mean=200, sd=20) 的积分不是 1

转载 作者:行者123 更新时间:2023-12-04 11:55:58 26 4
gpt4 key购买 nike

我试图计算期望值为 200 和标准差为 20 的正态分布密度的积分。从 -Inf 到 Inf 这应该是 1。

我得到以下信息:

> integrate(dnorm, mean=200, sd=20,-Inf, Inf)$value
[1] 1.429508e-08

对于低于 169 的预期值,我得到正确的值 1。如何获得更大的期望值的正确值?

最佳答案

或者

integrate(dnorm, mean=200, sd=20, lower= -Inf, upper= Inf, abs.tol = 0)$value
[1] 1

here .

要查看发生了什么,请注意以下分割的数量:

js <- integrate(dnorm, mean=200, sd=20, lower = -Inf, upper = Inf)
as <- integrate(dnorm, mean=200, sd=20, lower = -1e4, upper = 1e4)
cj <- integrate(dnorm, mean=200, sd=20, lower = -Inf, upper = Inf, abs.tol = 0)

str(js)
List of 5
$ value : num 1.43e-08
$ abs.error : num 2.77e-08
$ subdivisions: int 2
$ message : chr "OK"
$ call : language integrate(f = dnorm, lower = -Inf, upper = Inf, mean = 200, sd = 20)
- attr(*, "class")= chr "integrate"

str(as)
List of 5
$ value : num 1
$ abs.error : num 2e-07
$ subdivisions: int 9
$ message : chr "OK"
$ call : language integrate(f = dnorm, lower = -10000, upper = 10000, mean = 200, sd = 20)
- attr(*, "class")= chr "integrate"

str(cj)
List of 5
$ value : num 1
$ abs.error : num 9.37e-05
$ subdivisions: int 12
$ message : chr "OK"
$ call : language integrate(f = dnorm, lower = -Inf, upper = Inf, mean = 200, sd = 20, abs.tol = 0)
- attr(*, "class")= chr "integrate"

关于r - dnorm(x, mean=200, sd=20) 的积分不是 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45664762/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com