I want to make a plot using curve for multiple parameters.
For example, say I have the following distribution function for the binomial distribution:

I can plot curve for a probability mass function likeso:
curve(factorial(10)/(factorial(5)*factorial(5))*y^5*(1-y)^5, from=0, to = 1)
Because we want 0 < y < 1, however this won't work for multiple variables as from = 0, to = 1 will only apply for a single variable.
So - how can I get curve to work for something like:
curve(factorial(10)/(factorial(10-x)*factorial(x))*y^x*(1-y)^{10-x}, from=0, to = 1)
But also to indicate the the distribution function for x is less than or equal to 5, so from = 0, to = 5?
I guess you can use dbinom directly
curve(dbinom(5, 10, y), xname = "y")

or if you need to vary x, you can try
sapply(0:10, function(k) curve(dbinom(k, 10, y), xname = "y", add = TRUE, ylim = c(0, 1)))

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With