531f10R - STAT 531: R H. Kim Department of Mathematics and...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
STAT 531: R H. Kim Department of Mathematics and Statistics University of Calgary Fall 2010 H.Kim 1/15
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
download R from http://www.r-project.org/ base R some function and data that are not part of base R , download functions from the R web-site to see what packages you have, use the commend: library() > library(faraway) > data(stackloss) > names(stackloss) [1] "Air.Flow" "Water.Temp" "Acid.Conc." "stack.loss" > getwd() [1] "/Users/hmkim" > setwd("~/Desktop/531Lecture/") > getwd() [1] "/Users/hmkim/Desktop/531Lecture" to read data > stone<-read.csv("stone.csv", header=T, sep=",") > names(stone) [1] "site" "Northing" "Easting" "Sept" "Observers" "length" [7] "width" "height" Fall 2010 H.Kim 2/15
Background image of page 2
> x<- c(1:6) > mean(x) [1] 3.5 > median(x) [1] 3.5 > sd(x) [1] 1.870829 > x[1:2] [1] 1 2 > cumsum(x) [1] 1 3 6 10 15 21 > cumsum(x)/(1:5) [1] 1.0 1.5 2.0 2.5 3.0 3.5 > xmat <- matrix(x, ncol=2,byrow=T) > xmat [,1] [,2] [1,] 1 2 [2,] 3 4 [3,] 5 6 Fall 2010 H.Kim 3/15
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Normal Random Variable: N (mean , sd 2 ) > # density > # dnorm(x, mean = 0, sd = 1) > dnorm(0) == 1/ sqrt(2*pi) [1] TRUE > dnorm(1) == exp(-1/2)/ sqrt(2*pi) [1] TRUE > # distribution function > # pnorm(q, mean = 0, sd = 1 ) > pnorm(0) [1] 0.5 > pnorm(0, 1, 2) [1] 0.3085375 Fall 2010 H.Kim 4/15
Background image of page 4
> # quantile function > # qnorm(p, mean = 0, sd = 1) > qnorm(0) [1] -Inf > qnorm(0.5) [1] 0 > # random generation > # rnorm(n, mean = 0, sd = 1) > rnorm(5) [1] -1.4145325 1.5030445 -0.1664214 -0.3509735 0.2817680 Fall 2010 H.Kim 5/15
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
> y [1] 0.54194183 0.34096686 0.22437429 0.78366217 0.19454850 0.81433673 0.61942135 [8] 0.08064899 0.66096738 0.94694022 > dnorm(y,0,1) [1] 0.3444560 0.3764132 0.3890255 0.2934636 0.3914635 0.2863585 0.3293020 [8] 0.3976470 0.3206589 0.2547974 > 0.3 < dnorm(y,0,1) [1] TRUE TRUE TRUE FALSE TRUE FALSE TRUE TRUE TRUE FALSE > x <- y[0.3 < dnorm(y,0,1)]
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 15

531f10R - STAT 531: R H. Kim Department of Mathematics and...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online