Reputation: 210
As the title says, I'm trying to plot the CDF of a N(0,1) distribution between some values a, b. I.e. Phi_0,1 (a) to Phi_0,1 (b). For some reason I'm having issues finding information on how to do this.
Upvotes: 1
Views: 5391
Reputation: 146174
You can use curve
to do the plotting, pnorm
is the normal probability (CDF) function:
curve(pnorm, from = -5, to = 2)
Adjust the from
and to
values as needed. Use dnorm
if you want the density function (PDF) instead of the CDF. See the ?curve
help page for a few additional arguments.
Or using ggplot2
library(ggplot2)
ggplot(data.frame(x = c(-5, 2)), aes(x = x)) +
stat_function(fun = pnorm)
Generally, you can generate data and use most any plot function capable of drawing lines in a coordinate system.
x = seq(from = -5, to = 2, length.out = 1000)
y = pnorm(x)
Upvotes: 2