Time is really moving fast this semester, isn't it? We are already submitting our Module 6 assignment, part two of a block focused on math and simulations. This module provided a lot of insight and instruction about related transposing matrix, multiplying it by a vector, finding the inverse of a matrix, and finding its determinant as well. These are some challenging concepts to grasp for some of us.
Instead of using 6 for nrows, I went with 10 for both A and B matrix data sets. In my opinion, the less conflicts the better. Transposing a matrix is very easy: t(matrix). Inputting the command t(A) output the matrix with 10 rows and 10 columns, cells numbering 1 to 100. Inputting the command t(B) output the matrix with 100 rows and 10 columns, cells numbering 1 to 1,000.
Multiplying the matrix by a vector was the next step, and I needed to create a vector. I did so easily and multiplied: X = a*A, Y = b*B. I also created a vector Z = a*B and displayed that as well to evaluate how it differed. After this, I reverted back to nrow=6 for both 1:100 and 1:1000. I then reassigned a to 1:17 and b to 1:167 and used %*% to multiply a against A, then B against b.
The next step in the assignment was to reverse the matrix. I changed A matrix to 1:4 with an nrow=2 and was able to invert using solve(A). It clearly became inverted! I then created a matrix using runif to generate random numbers ranging from 0 to 50 with 25 as the median. I then found the determinant by using det(A).
R can be pretty simple if you know your equations and can wrap your head around these concepts. It's not always easy, but I am not finding it to be quite as difficult for me to understand as C++ or Java, for example. I'm looking forward to more!
No comments:
Post a Comment