In[]:=
deploy
Fri 25 Jun 2021 09:03:30
In[]:=
With[{n=7},avec=Array[a,n];xvec=Array[x,n-1];xvec2=xvec~Join~{1-Total[xvec]};dist=DirichletDistribution[ConstantArray[1/2,n]];{Expectation[avec.xvec2,xvecdist],Expectation[,xvecdist]}//FullSimplify]
2
(avec.xvec2)
Out[]=
(a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]),(3+3+3+2a[3]a[4]+3+2a[3]a[5]+2a[4]a[5]+3+2a[3]a[6]+2a[4]a[6]+2a[5]a[6]+3+2(a[3]+a[4]+a[5]+a[6])a[7]+3+2a[2](a[3]+a[4]+a[5]+a[6]+a[7])+2a[1](a[2]+a[3]+a[4]+a[5]+a[6]+a[7]))
1
7
1
63
2
a[1]
2
a[2]
2
a[3]
2
a[4]
2
a[5]
2
a[6]
2
a[7]
In[]:=
stddev[n_]:=Module[{},avec=Table[1/i,{i,1,n}];xvec=Array[x,n-1];xvec2=xvec~Join~{1-Total[xvec]};dist=DirichletDistribution[ConstantArray[1/2,n]];Sqrt[Expectation[,xvecdist]]//N];gendata[f_,max_,n_]:=TableWithx=Floor,{x,f[x]},{i,1,n};gendata[f_,max_,n_]:=TableWithx=Floor,{x,f[x]},{i,0,n};max=60;ShowLogLogPlot,{x,1,max},PlotLegends"sqrt[x]",ListLogLogPlot[gendata[stddev,max,10]],PlotLabel"variance shrinks faster than Law of Large Numbers"
2
(avec.xvec2)
i
n
(max)
i
n
(max)
1
Sqrt[x]
Out[]=
sqrt[x] |
Graphical Version
Graphical Version
cylinder[t_]:=With{x=Cos[t],y=Sin[t]},Graphics3D@Cylinder{{x,y,0},{x,y,+3}},1100;plot3da=Plot3D[{0,+3},{x,-1,1},{y,-1,1},RegionFunctionFunction[{x,y,z},x^2+y^2≤1],MeshFunctions{#3&},BoxedFalse,AxesNone,PlotStyleOpacity[0.5]];plot3d[t_]:=Show[plot3da,cylinder[t]]plot2da=Plot[With[{x=Cos[t],y=Sin[t]},+3],{t,0,2Pi}];point[t_]:=ListPlot[With[{x=Cos[t],y=Sin[t]},{{t,+3}}],FillingAxis]plot2d[t_]:=Show[plot2da,point[t],ImageSize300];plotCombined[t_]:=GraphicsRow[{plot3d[t],plot2d[t]},ImageSize600,Spacings0];plots=Table[plotCombined[t],{t,0,2Pi,2Pi/20}];plots//First
2
x
2
y
2
x
2
y
2
x
2
y
2
x
2
y
Export["quadratic_form.gif",ListAnimate[plots],"AnimationRepetitions"Infinity]