简体   繁体   English

是否有 R 函数来计算累积分布函数?

[英]Is there an R function to compute the cumulative distribution function?

I want to plot a power function of the form B = Phi(-1.96 + 35.7*x) versus x.我想绘制 B = Phi(-1.96 + 35.7*x) 与 x 形式的幂函数。 Where Phi denotes the cumulative distribution function and where x is between 0 and 0.4.其中 Phi 表示累积分布函数,其中 x 介于 0 和 0.4 之间。 I tried the code below but it doesn't return the expected plot.我尝试了下面的代码,但它没有返回预期的情节。

x = seq(0,0.5,by=0.01)
ggplot(data.frame(x=x, cumulative=pnorm(-1.96 + sqrt(0.5*50*51)*x,0,1)), aes(x,cumulative))+geom_line()+ggtitle('Power')

Are you looking for this:你在找这个吗:

#Function
Phi <- function(x){-1.96 + 35.7*x}
x <- seq(0,0.3,by=0.01)
Phi <- Vectorize(Phi)
dx <- 0.01
plot(x, cumsum(Phi(x) * dx), type = "l", ylab = "cummulative probability", main = "My CDF")

Output:输出:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM