# 24.11.2010 x<-c(0,0,1,1,2) y<-c(1,2,0,1,0) f<-function(x,y) (x+2*y)/12 z<-f(x,y) xyz<-cbind(x,y,z) cloud(z~x*y,data=xyz,xlim=c(-1,3),ylim=c(-1,3),type=c("p","h"), scales=list(arrows=F,distance=1.65,y=list(at=0:2), x=list(at=0:2)), screen=list(x=-35,y=-35,z=-45)) f.cloud<-cloud(z~x*y,data=xyz,xlim=c(-1,3),ylim=c(-1,3),type=c("p","h"), scales=list(arrows=F,distance=1.65,y=list(at=0:2), x=list(at=0:2)), screen=list(x=-35,y=-35,z=-45)) print(f.cloud) # Tällä tnf, reunajakaumat, plot m <- matrix(1:4,2) prop.table(m) prop.table(m,1) prop.table(m,2) ============ # Piirtofunktio function.draw<-function(f,low=-1,hi=1,n=30) { r<-seq(low,hi,length=n) z<-outer(r,r,f) persp(r,r,z,xlab="x",ylab="y",zlab="z",theta = -90, phi = 30,ticktype="detailed") } # f(x,y)=8*x*y f3<-function(x,y){ifelse(x>=y,8*x*y,0)} function.draw(f3,0,1,25) ###################### # Tasajakauma Tas(0,1) ###################### # Kf Ftas <- function(x,y) {ifelse(x>=0 & x<=1 & y>=0 & y<=1,x*y,0) } function.draw(Ftas,0,1,25) #tf f(x,y)=1 fTas<-function(x,y) x*y/(x*y) function.draw(fTas,0,1,25) ###################### # Tasajakauma Tas(0,1) ###################### x <- seq(0, 2, length= 30) y <- x f <- function(x,y) {ifelse(x>=0 & x<=1 & y>=0 & y<=1,1,0) } z <- outer(x, y, f) #z[is.na(z)] <- 1 #op <- par(bg = "white") #persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue") persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue",ticktype="detailed") ########## function.draw<-function(f,low=-1,hi=1,n=30) { r<-seq(low,hi,length=n) z<-outer(r,r,f) persp(r,r,z,xlab="x",ylab="y",zlab="z",theta = -45, phi = 15,ticktype="detailed") }