-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.Rhistory
73 lines (73 loc) · 1.84 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
knitr::opts_chunk$set(echo = TRUE) #ignore this
### DO NOT CHANGE ANYTHING IN THIS CODE CHUNK!!!
M = read.csv("./Matrix_Algebra/img.txt", header = FALSE)
### DO NOT CHANGE ANYTHING IN THIS CODE CHUNK!!!
M = read.csv("./Matrix_Algebra/img.txt", header = FALSE)
getwd()
M = read.csv("./Matrix_Algebra/img.txt", header = FALSE)
### DO NOT CHANGE ANYTHING IN THIS CODE CHUNK!!!
M = read.csv("./Matrix_Algebra/img.txt", header = FALSE)
M = as.matrix(M)
n = nrow(M)
p = ncol(M)
set.seed(123)
A <- diag(rnorm(p))
set.seed(456)
B <- tcrossprod(as.matrix(array(rnorm(25), c(5,5))))
set.seed(789)
x <- abs(rnorm(p))
set.seed(101)
y <- rnorm(n)
set.seed(112)
H <- as.matrix(array(rnorm(n*p), c(n,p)))
### DO NOT CHANGE ANYTHING IN THIS CODE CHUNK!!!
M = read.csv("./Matrix_Algebra/img.txt", header = FALSE)
M = as.matrix(M)
n = nrow(M)
p = ncol(M)
set.seed(123)
A <- diag(rnorm(p))
set.seed(456)
B <- tcrossprod(as.matrix(array(rnorm(25), c(5,5))))
set.seed(789)
x <- abs(rnorm(p))
set.seed(101)
y <- rnorm(n)
set.seed(112)
H <- as.matrix(array(rnorm(n*p), c(n,p)))
# Correct step:
M <- M %*% A
# This will perform the calculation, but not update M
# M %*% A
# This will result in an error because the dimensions do not match
# A %*% M
### DO NOT CHANGE ANYTHING IN THIS CODE CHUNK!!!
M = read.csv("./Matrix_Algebra/img.txt", header = FALSE)
M = as.matrix(M)
n = nrow(M)
p = ncol(M)
set.seed(123)
A <- diag(rnorm(p))
set.seed(456)
B <- tcrossprod(as.matrix(array(rnorm(25), c(5,5))))
set.seed(789)
x <- abs(rnorm(p))
set.seed(101)
y <- rnorm(n)
set.seed(112)
H <- as.matrix(array(rnorm(n*p), c(n,p)))
# Correct step:
M <- M %*% A
M <- t(t(M)*x)
Y <- diag(y)
M <- solve(Y) %*% M
det <- det(B)
M <- M + det
evs <- eigen(B)
M <- M * sum(evs$vectors[,3])
M <- M*t(tcrossprod(x,y))
svd <- svd(H)
M <- M * (100*svd$u)
tr <- sum(svd$d)
M = M/tr
image(M, col = gray((1:100)/100), asp = 1, axes = FALSE)