Chr*_*s95 1 statistics r function distribution
鉴于以下功能:
f(x) = (1/2*pi)(1/(1+x^2/4))
Run Code Online (Sandbox Code Playgroud)
如何识别它的分布并在R中编写此分布函数?
所以现在这是你的功能(希望你知道如何编写R函数;如果没有,请检查编写自己的函数):
f <- function (x) (pi / 2) * (1 / (1 + 0.25 * x ^ 2))
Run Code Online (Sandbox Code Playgroud)
f定义在(-Inf, Inf)这个范围上的积分给出了一个不确定的积分.幸运的是,它以Inf速度接近x ^ (-2),因此积分定义良好,并且可以计算:
C <- integrate(f, -Inf, Inf)
# 9.869604 with absolute error < 1e-09
C <- C$value ## extract integral value
# [1] 9.869604
Run Code Online (Sandbox Code Playgroud)
然后你要标准化f,因为我们知道概率密度应该整合到1:
f <- function (x) (pi / 2) * (1 / (1 + 0.25 * x ^ 2)) / C
Run Code Online (Sandbox Code Playgroud)
您可以通过以下方式绘制密度:
curve(f, from = -10, to = 10)
Run Code Online (Sandbox Code Playgroud)