简体   繁体   中英

How to plot the Standard Normal CDF in R?

As the title says, I'm trying to plot the CDF of a N(0,1) distribution between some values a, b. Ie Phi_0,1 (a) to Phi_0,1 (b). For some reason I'm having issues finding information on how to do this.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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