In[]:=
deploy
Wed 10 Aug 2022 11:04:32
​
In[]:=
decay=1.;​​d=200;​​evals=Table[
-decay
i
,{i,1,d}];​​mean=ConstantArray[0.1,d];​​sigma=DiagonalMatrix@evals;​​dist=MultinormalDistribution[mean,sigma];​​frobEst[samples_]:=​​Ex1=Norm[Mean[samples]];​​Ex2=Mean[
2
Norm[#]
&/@samples];​​Ex4=Mean[
4
Norm[#]
&/@samples];​​(*estimateofTr
2
(sigma)
Tr(
2
sigma
)*);​​0.5(Ex4-
2
Ex2
+2
4
Ex1
)​​;​​​​estimateR1[X_]:=With{sigma=X.X},
2
Norm[X,"Frobenius"]
Norm[sigma]
;​​estimateR2[X_]:=With{sigma=X.X},
2
2
Norm[X,"Frobenius"]
Norm[sigma,"Frobenius"]
;​​R1=
Tr[sigma]
Norm[sigma]
;​​R2=
2
Tr[sigma]
Norm[sigma,"Frobenius"]
;​​​​​​numSamples=100;​​maxBatch=10;​​​​meanFrobEst[k_]:=Mean[Table[frobEst[RandomVariate[dist,k]],{numSamples}]];​​​​batchSizes=First/@Partition[Range[maxBatch],Max[1,Floor[maxBatch/10]]];​​estimates=Table[frobEst[RandomVariate[dist,k]],{k,batchSizes}];​​estimates=Table[meanFrobEst[k],{k,batchSizes}];​​plot1=ListPlot[estimates,Filling->Axis,PlotLegends->{"estimate"},PlotRange->All];​​plot2=Plot[Labeled[
2
Norm[sigma,"Frobenius"]
,NumberForm[
2
Norm[sigma,"Frobenius"]
,3],Above],{x,0,maxBatch},PlotStyle->Dashed,PlotLegends->{"true value"},PlotLabel->StringForm["d=``, r=``, R=``",d,NumberForm[R1,5],NumberForm[R2,5]],AxesLabel->{"num samples","estimate"}];​​Show[plot2,plot1,PlotRange->All]
Out[]=
true value
estimate