Question: 9 5 . We construct the SPCA process using the R language. The process is repeated to observe how each element of the vector
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 ; p ; x nprandon.normalsizenpreshapel
p
lambdseq nparange l
# computation of uv
lanbd ; nl
g np : zerosn p
for j in range p: x: j x: j npneanx: j
for j in range p: x: j x: j npsqrtnpsumnp
squarex: j
r n; v nprandon nornal sizep
for h in rangen:
z npdotx v; u npdotxT z
if npsumnpsquareu: u u npsqrtnp
sumnpsquareu
for k in range p:
nl listnparangek; nl listnparangekl p
; z nl nl
for i in rangen:
rinpsumu xi:
npsumnpsquareu sumxi z
vz
s npsumnpdotx: k rn
vk ## BlankI ##
if npsumnpsquarevl: v ## Blank ##
gh: v
# Display
gnax npmaxg; gnin npming
cycle pltrcParamsaxespropcycle"bykeycolor
fig pltfigurefigsize
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
