6bffa989a3417b76ee2199d377f50b5f594f5209
Michi add sheet 7

Michi authored 11 years ago

1) #Problem 1
2) 
3) #definition of a straight line function
Michi add 2.2

Michi authored 11 years ago

4) linrel=function(x,m,b) m*x+b
Michi add sheet 7

Michi authored 11 years ago

5) 
6) #definition x-Vctor
7) x_vec=seq(-1,3,0.1)
8) 
9) #definition y-vector
Michi add 2.2

Michi authored 11 years ago

10) y_vec=linrel(x_vec,1,0)
Michi add sheet 7

Michi authored 11 years ago

11) #plotting x-vector vs. y-vector
12) plot(x_vec, y_vec, type="l", col="black", xlab='x',ylab='f(x)=y')
13) 
14) #generating mock data point for 0 <= x <= 2 for 10 equaly spaced points
15) equ_points=10
Michi new 2 i

Michi authored 11 years ago

16) mock_vec = rep(NA,10)
17) x_vec_2 =seq(0,2, 2/(equ_points-1))
18) mock_vec = rnorm({1:10},mean = x_vec_2, sd =  0.4)
19) points(x_vec_2,mock_vec, col="red", type="p")
20) 
21) ##Problem2
22) conrel =function(b) b
23) quarel =function(x,a,m,b) a*x**2 + m*x+b
24) 
25) reso = 10  #the resolution