In[]:=

deploy

Tue 14 May 2019 13:27:33

## Util

Util

## One Dimensional FD

One Dimensional FD

In[]:=

computeVariance[η_]:=Module[{},dsize=10000;X=RandomVariate[NormalDistribution[],{dsize}];Y=RandomVariate[NormalDistribution[],{dsize}];XY=Transpose[{X,Y}];step[w_,xy_]:=Module[{x,y},x=xy[[1]];y=xy[[2]];w-η(wx+y)x];loss[w_,xy_]:=Module[{x,y},x=xy[[1]];y=xy[[2]];0.5*];ws=Most@FoldList[step,0,XY];losses=MapThread[loss,{ws,XY}];grad[i_]:=(ws[[i]]X[[i]]+Y[[i]])X[[i]];grads=grad/@Range[dsize];ol=ws*grads;or=0.5ηgrads*grads;(*adjustratiobyfactorof4η*)4ηVariance[ol]Variance[or]]

2

(wx-y)

In[]:=

stepLengths={0.001,0.002,0.003,0.004,0.005,0.006,0.007,0.008,0.009,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.1};variances=computeVariance[#]&/@stepLengths;ListLinePlot[{stepLengths,variances}//Transpose,PlotLabel"4ηVariance(ol)/Variance(or)",AxesLabel{"η","adjusted ratio"}]

Out[]=