Reputation: 977
I am trying to find the y-values of points on a beta curve.
This is my beta; let's say I would like to find the point whose x-value is 0.6, for example:
x=seq(0,1,length=100)
y=dbeta(x,7,2)
plot(x,y, type="l", col="blue")
abline(v=0.6)
I have tried to add the corresponding point, but for some reason it does not work:
points(0.6, beta(7, 2), cex=3, pch=20, col="black")
Once fixed this problem, how can I find the y-value? I looked online; I found some examples using approxfun but I don't know how to apply it to this problem.
Upvotes: 0
Views: 224
Reputation: 226162
You need to use dbeta()
instead of beta()
(assuming that's not a typo), and specify all three of x
, shape1
, and shape2
. I think you want
points(0.6, dbeta(0.6, shape1=7, shape2=2),
cex=3, pch=20, col="black")
If you want to store the actual y-value in a variable, use
bval <- dbeta(0.6, shape1=7, shape2=2)
Upvotes: 2