This question is an exact duplicate of:
- How to solve a set of Linear equations? 2 answers
I've got to solve this system of equations:
aQ + bP = c
dQ + eP = f
I have to find 100 values Q and P that solve the systems with 100 randomly drawn coefficients from the following distributions:
a ~ N( 100; 10)
b ~ N(-1;0.1)
c ~ N(10;1)
d ~ N(10;0.1)
e ~ N(100;10)
f ~ N(10;0.1)
Which I did by doing the following:
a<-rnorm(100,mean=100,sd=10)
b<-rnorm(100,mean=-1,sd=.1)
c<-rnorm(100,mean=10,sd=1)
d<-rnorm(100,mean=10,0.1)
e<-rnorm(100,mean=100,sd=10)
f<-rnorm(100,mean=10,0.1)
Then I made matrix:
O <- matrix(data=c(a,b,c),1,1)
P<- matrix(c(d,e,f),1,1)
Finally solved it using:
solve(O,P)
My problem is that I'm trying to get 100 solutions but this code returns just one solution. After obtaining the 100 values for Q and P I need to make a plot with all of the values.