In[]:=
deploy
Mon 27 Dec 2021 17:09:23
Small n
Small n
In[]:=
setupProblem[nn_]:=Clear[x];n=nn;hs=Table,{i,1,n};xs=Array[x,n];Z=;(*Z=Integrate[1,xs∈R]*);normalRatio:=dist=MultinormalDistribution[IdentityMatrix[n]];TransformedDistribution..,xsdist;setupProblem[2];Mean[normalRatio]
1
i
2
n/2
π
Gamma[n/2]
2
hs
2
xs
3
hs
2
xs
Out[]=
2
7
2
)Large n
Large n
In[]:=
sampleLR[nn_,samples_]:=n=nn;hs=Table,{i,1,n};xs=Array[x,n];dist=MultinormalDistribution[IdentityMatrix[n]];RandomVariateTransformedDistribution..,xsdist,samples;data=sampleLR[1000,1000000];Mean[data]skd=SmoothKernelDistribution[data,Automatic,{"Bounded",{0,10},"Epanechnikov"}];img=Plot[PDF[skd,x],{x,0,10},FillingAxis,PlotRangeAll]
1
i
2
hs
2
xs
3
hs
2
xs
Out[]=
1.98912
Out[]=
Dot product representation
Dot product representation
In[]:=
solveDot[nn_]:=n=nn;hs=Table,{i,1,n};xs=Array[x,n];dist=MultinormalDistribution[DiagonalMatrix[]];distz=TransformedDistribution,xsdist;z=NExpectation[xs,xsdistz];Total[z*Range[n]];solveDot[2]
1
i
3
hs
2
xs
Total[]
2
xs
Out[]=
1.2612
In[]:=
solveDot[3]
Out[]=
1.41505
Animation
Animation
In[]:=
exportAnim[fn_,images_,is_]:=Module[{},rasters=images;SetDirectory[NotebookDirectory[]];SetDirectory["export"];Export[fn,rasters,"AnimationRepetitions"Infinity]];cylinder[t_]:=With{x=Cos[t],y=Sin[t]},Graphics3D@Cylinder{x,y,0},x,y,+1/2+1/4,1100;plot3da=Plot3D0,+12,+14,{x,-1,1},{y,-1,1},MeshFalse,RegionFunctionFunction[{x,y,z},x^2+y^2≤1],MeshFunctions{#3&},BoxedFalse,AxesNone,PlotStyleOpacity[0.5],PlotPoints50;plot3d[t_]:=Show[plot3da,cylinder[t]]blue=ColorData[97,"ColorList"][[1]];(*plot2da=Plot[Callout[+3,"",Above],Callout[+3,"",Below],Callout[2,"",Above],{t,0,2Pi},PlotStyle{blue,blue,Dashed},AxesOrigin{0,0}];*)plot2da=Plot++,Callout[1.261,"1.261",Above],{t,0,2Pi},AxesOrigin{0,0},PlotStyle{Automatic,Dashed},PlotRangePadding.75,Ticks{{Pi/2,Pi,3Pi/2,2Pi},{0,1,1.5,2}},PlotRangeAll;point[t_]:=ListPlotWith{x=Cos[t],y=Sin[t]},t,++,PlotStylePointSize[Large],FillingAxis,FillingStyleDirective[Orange,Opacity[0.8]]plot2d[t_]:=Show[plot2da,point[t],ImageSize400];plotCombined[t_]:=GraphicsRow[{Show[plot3d[t],ImageSize600],Show[plot2d[t],ImageSize500]}]plotCombined[2]
2
x
2
y
2
x
2
y
2
x
2
y
2
x
2
y
2
Cos[t]
2
Sin[t]
λ
1
2
Cos[t]
2
Sin[t]
λ
2
λ
ave
2
Cos[t]
2
Sin[t]
4
2
Cos[t]
2
Sin[t]
8
2
Cos[t]
2
Sin[t]
4
2
Cos[t]
2
Sin[t]
8
Out[]=
Distribution plots
Distribution plots
Two dimensions explicit
Two dimensions explicit