Line Line Picking

Author

Eric W. Weisstein
January 20, 2006

This notebook downloaded from http://mathworld.wolfram.com/notebooks/ComputationalGeometry/LineLinePicking.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/LineLinePicking.html.

©2006 Wolfram Research, Inc. except for portions noted otherwise

Distribution

Plot3D[Abs[x2-x1],{x1,0,1},{x2,0,1}]

v4.2.1

Integrate[DiracDelta[d-Abs[x2-x1]],{x1,0,1},{x2,0,1}]

v5.0.0

(i=Integrate[DiracDelta[d-Abs[x2-x1]],{x1,0,1},{x2,0,1}])//Timing

FullSimplify[i,0<d<1]

v5.0.1

(i=Integrate[DiracDelta[d-Abs[x2-x1]],{x1,0,1},{x2,0,1}])//Timing

FullSimplify[i,0<d<1]

v5.1

Integrate[DiracDelta[d-Abs[x2-x1]],{x1,0,1},{x2,0,1}]

v5.2

Integrate[DiracDelta[d-Abs[x2-x1]],{x1,0,1},{x2,0,1}]

v6

Integrate[DiracDelta[d-Abs[x2-x1]],{x1,0,1},{x2,0,1},Assumptions->0<d<1]

i=Integrate[DiracDelta[d-Abs[x2-x1]],{x1,0,1},{x2,0,1}]

FullSimplify[i,0<d<1]

FullSimplify[i/.HeavisideTheta->UnitStep,0<d<1]

V7

Integrate[DiracDelta[d-Abs[x2-x1]],{x1,0,1},{x2,0,1},Assumptions->0<d<1]

Monte Carlo

Solve[Integrate[c(1-d),{d,0,1}]==1,c]

data=Abs[Subtract@@@Table[Random[],{10^6},{2}]];//Timing

Through[{Min,Max}[data]]

{Through[{Mean,Variance}[data]],{1/3,1/18}//N}

With[{d=.01},{Count[data,_?(0<#<d&)]/Length[data]//N,2(1-d)d}]

With[{d=.02},{Count[data,_?(0<#<d&)]/Length[data]//N,2(1-d)d}]

<<Graphics`Graphics`

With[{bin=100},BarChart[Length/@Split[Ceiling[bin Sort[data]]],Ticks->None,BarEdges->None,BarSpacing->-.2,PlotRange->{{0,bin},All},AxesLabel->TraditionalForm/@{d,P[d]}]]

Mean

v5.2

Integrate[Abs[x1-x2],{x1,0,1},{x2,0,1}]

V7

Integrate[Abs[x1-x2],{x1,0,1},{x2,0,1}]

Plot

Integrate[2(1-d),{d,0,x}]//Simplify

Show[GraphicsArray[
Block[{$DisplayFunction=Identity},
{Plot[2(1-d),{d,0,1},PlotStyle->Red,AxesLabel->TraditionalForm/@{d,PDF[d]}],
Plot[x(2-x),{x,0,1},PlotStyle->Red,AxesLabel->TraditionalForm/@{d,CDF[d]}]
}
]],ImageSize->500]

Raw Moments

V5

Integrate[2(1-d)d^m,{d,0,1},Assumptions->m≥0]//Factor

Table[(2/((1+m) (2+m))),{m,20}]

Denominator[%]

Central Moments

V5

Integrate[2(1-d)(d-1/3)^m,{d,0,1},Assumptions->m>0&&m∈Integers]//FullSimplify

TraditionalForm[%]

Table[(((3^(-2-m)) ((2^(3+m))+2 (((-1))^m) (5+3 m)))/((1+m) (2+m))),{m,10}]

V7

Integrate[2(1-d)(d-1/3)^m,{d,0,1},Assumptions->m>0&&m∈Integers]//FullSimplify