Question: 9 5 . We construct the SPCA process using the R language. The process is repeated to observe how each element of the vector

95. We construct the SPCA process using the R language. The process is repeated to observe how each element of the vector \( v \) changes with the number of iterations. Fill in the blanks, execute the process, and display the output as a graph.
```
# Data Generation
n =100; p =5; x = np.randon.normal(size=n*p).reshape(-l,
p)
lambd_seq = np.arange (0,1l)/10
# computation of u,v
lanbd =[0.001,0.00001]; nl =100
g = np : zeros((n, p))
for j in range (p): x[:, j]= x[:, j]- np.nean(x[:, j])
for j in range (p): x[:, j]= x[:, j]/ np.sqrt(np.sum(np.
square(x[:, j])))
r =[0]* n; v = np.randon nornal (size=p)
for h in range(n):
z = np.dot(x, v); u = np.dot(x.T, z)
if np.sum(np.square(u))>0.00001: u = u / np.sqrt(np.
sum(np.square(u)))
for k in range (p):
nl = list(np.arange(k)); nl = list(np.arange(k+l, p
)); z = nl + nl
for i in range(n):
r[i]=(np.sum(u * x[i,:])
- np.sum(np.square(u))* sum(x[i, z]*
v[z]))
s = np.sum(np.dot(x[:, k], r))/n
v[k]= ## Blank(I) ##
if np.sum(np.square(v))>0.0000l: v = ## Blank(2) ##
g[h,:]= v
# Display
g_nax = np.max(g); g_nin = np.min(g)
cycle = plt.rcParams["axes.prop_cycle"].by_key()["color"]
fig = plt.figure(figsize=(8,5))
```
9 5 . We construct the SPCA process using the R

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!