WEEK3-Using the z distribution in R
2014-09-25 13:44
246 查看
Explore Statistics with R (EDX)
WEEK3-Using the z distribution in R视频笔记
一、 一些概念和用法1. The Normal Distribution
Density, distribution function, quantile function and random generation for the normal distribution with mean equal to mean and standard deviation equal to sd.
dnorm(x, mean = 0, sd = 1, log = FALSE)
pnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)
qnorm(p, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)
rnorm(n, mean = 0, sd = 1)
2. ?dt() ; ?dpois() ; ?dbinom() ; ?dchisq()
The Student t Distribution;The Poisson Distribution;The Binomial Distribution;The (non-central) Chi-Squared Distribution
最后一个是卡方分布,英文长得很好吃的样子。。
二、画图画图
1. dnorm() #Density function
x<-seq(-4, 4, 0.01) #start at minus-four, continue to number four and the interval between the points is 0.01 plot(x, dnorm(x), type="l") #l = line
![](http://img.my.csdn.net/uploads/201409/25/1411618946_3982.jpeg)
2. pnorm() #Distribution function, or Cumulative distribution function 所以其实是累积分布函数
plot(x, pnorm(x))
![](http://img.my.csdn.net/uploads/201409/25/1411619682_2229.jpeg)
3. qnorm() #Quantile function
> qnorm(0.25) #the value at the 25th percentile [1] -0.6744898
> qnorm(c(0.025, 0.975)) #confidence interval #置信区间 [1] -1.959964 1.959964
三、例子
1. z-tests
(A Z-test is any statistical test for which the distribution of the test statistic under the null hypothesis can be approximated by a normal distribution. ---from wiki)
bt <- seq(60, 120, 1) plot(bt, dnorm(bt, 90, 10), type="l", xlim=c(60, 120), main="blood pressure") #mean = 90, standard deviation = 10
![](http://img.my.csdn.net/uploads/201409/25/1411621924_4844.jpeg)
2. one tailed test #单侧检验
> bt <- seq(60, 120, 1) > plot(bt, dnorm(bt, 90, 10), type="l", xlim=c(60, 120), main="one tailed test") > pnorm(72, 90, 10) # probability of randomly selecting a subject at 72 or lower [1] 0.03593032 > abline(v=72) # Draw a line for 72 > cord.x <- c(60,seq(60,72,1),72) > cord.y <- c(0,dnorm(seq(60, 72, 1), 90, 10),0) > polygon(cord.x,cord.y,col='skyblue') > text(70, 0.005, "blue area = p = 0.0359")
![](http://img.my.csdn.net/uploads/201409/25/1411623563_1249.jpeg)
3. two-tailed test #双侧检验
> bt <- seq(60, 120, 1) > plot(bt, dnorm(bt, 90, 10), type="l", xlim=c(60, 120), main="two-tailed test") > pnorm(72, 90, 10) [1] 0.03593032 > abline(v=72) > cord.x <- c(60,seq(60,72,1),72) > cord.y <- c(0,dnorm(seq(60, 72, 1), 90, 10),0) > polygon(cord.x,cord.y,col='skyblue') > cord.x1 <- c(108,seq(108,120,1),120) > cord.y1 <- c(0,dnorm(seq(108, 120, 1), 90, 10),0) > polygon(cord.x1,cord.y1,col='skyblue') > text(65, 0.005, round(pnorm(72, 90, 10), 3)) > text(115, 0.005, round(pnorm(72, 90, 10), 3)) > text(75, 0.02, " p = 0.072 " )
![](http://img.my.csdn.net/uploads/201409/25/1411623776_3786.jpeg)
相关文章推荐
- Creating a Web Control with an Expandable Property in the Designer by Using C#.
- Using MC.exe, message resources and the NT event log in your own projects
- Discover the Design Patterns You're Already Using in the .NET Framework
- An easy instance of using the template class in C++
- The way of using SqlCacheDependency in .net 2.0
- using WebRequest to get resource in the internet
- Using the FortiOS built-in packet sniffer
- Working with Data in ASP.NET 2.0 :: Using TemplateFields in the GridView Control
- Using the Enterprise Library Validation Application Block in ASP.NET - Part II
- Using the ASP.NET 2.0 ReportViewer in Local Mode
- Unlocking Information in the Microsoft Office System Using XML
- The Essentials for Using COM in Managed Code
- Using Explorer to get files in the GAC
- Understanding the 'using' statement in C#
- Using the Web Services and COM+ Event System in the .Net Application.
- how the process using the hard disk in linux
- Using the Network Functions in C# (Part I - User Functions)
- You cannot access the client's file system using the FileSystemObject in your ASP code
- Using the ASP.NET 2.0 ReportViewer in Local Mode
- Using the Enterprise Library Validation Application Block in ASP.NET - Part I