#-----------------------------------------------------# #--- Classical and Bayesian inference (AMS132) ---# #--- Class 1 ---# #-----------------------------------------------------# #-- remember to use ?function for help on the functions # "#" are used to write comments #-- try uring R as a calculator: 1+1 sqrt(25) # ?sqrt exp(10) # ?exp cos(pi) # ?cos sin(pi) #?sin #-- the exponential distribution with rate theta: # distribution function: pexp(2, rate=0.5) # ?pexp curve(pexp(x, 0.5), 0,10) curve(pexp(x, 0.5), 0,10, xlab="x", ylab="distribution function") # probabiity density function: dexp(2, rate=0.5) # the same as 0.5*exp(-0.5*2) curve(dexp(x, 0.5), 0,10, xlab="x", ylab="probability density function") # quantile function qexp(0.9, rate=0.5) curve(qexp(x, 0.5), 0, 1, xlab="probability", ylab="quantile function") # (pseudo) random variable generator rexp(1, rate=0.5)