Uniform Sum Distribution

Author

Eric W. Weisstein
January 10, 2009

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Statistics/UniformSumDistribution.nb.

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

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

Derivation

Combining Two Uniform Distributions

V5.2

i2=Integrate[DiracDelta[x1+x2-z],{x1,0,1},{x2,0,1}]

FullSimplify[i2,0<z<2]

V7

i2=Integrate[DiracDelta[x1+x2-z],{x1,0,1},{x2,0,1}]

FullSimplify[i2,0<z<2]

PiecewiseExpand[%,0<z<2]

FullSimplify[2-z+2 (-1+z) HeavisideTheta[1-z],0<z<1]

FullSimplify[2-z+2 (-1+z) HeavisideTheta[1-z],1<z<2]

FullSimplify[2-z+2 (-1+z) HeavisideTheta[1-z],z==1]

2-z+2 (-1+z) HeavisideTheta[1-z]/.z->1

Plot

Plot[2-z+2 (-1+z) UnitStep[1-z],{z,0,2},PlotStyle->Red]

Combining Three Uniform Distributions

V5.2

i3=Integrate[DiracDelta[x1+x2+x3-z],{x1,0,1},{x2,0,1},{x3,0,1}]

(i3/.{z->#})&/@{1,2}

FullSimplify[i3,0<z<3]

...wrong at z==1, 2...

(i3/.UnitStep[x_]->UnitStep[x]-If[x==0,1,0]/2/.{z->#})&/@{1,2}

FullSimplify[i3/.UnitStep[x_]->UnitStep[x]-If[x==0,1,0]/2,0<z<3]

{((z^2)/2),-(3/2)-(-3+z) z,(1/4) (6-(z^2)),(1/4) (-3-(-6+z) z)}/.z->1

{((z^2)/2),-(3/2)-(-3+z) z,(1/4) (6-(z^2)),(1/4) (-3-(-6+z) z)}/.z->2

Plot[%,{z,0,3},PlotStyle->Red]

V7

i3=Integrate[DiracDelta[x1+x2+x3-z],{x1,0,1},{x2,0,1},{x3,0,1}]

FullSimplify[i3,0<z<3]

Table[i3/.z->RandomReal[{-10,0}],{1000}]//Chop//Union

FullSimplify[i3<0]

Table[i3/.z->RandomReal[{3,10}],{1000}]//Chop//Union

FullSimplify[i3>3]

Plot[%,{z,0,3},PlotStyle->Red]

Combining nUniform Distributions

Inverse Fourier Transform

v4.2

InverseFourierTransform[(((((2 (E^((I t)/2)) Sin[(t/2)])/t)))^n),t,x]//Timing

InverseFourierTransform[(((((I(1-Exp[I t]))/t)))^n),t,x]//Timing

v5.1

InverseFourierTransform[(((((2 (E^((I t)/2)) Sin[(t/2)])/t)))^n),t,x]//Timing

InverseFourierTransform[(((((I(1-Exp[I t]))/t)))^n),t,x]//Timing

v6

InverseFourierTransform[(((((2 (E^((I t)/2)) Sin[(t/2)])/t)))^n),t,x]//Timing

InverseFourierTransform[(((((I(1-Exp[I t]))/t)))^n),t,x]//Timing

V7

InverseFourierTransform[(((((2 (E^(I t/2)) Sin[(t/2)])/t)))^n),t,x]//Timing

Sum

Sum[Binomial[n,k](x-k)^(n-1) (-1)^k Sign[x-k],{k,0,n}]/(n-1)!/2

UniformF[n_]:=InverseFourierTransform[(I(1-Exp[I t])/t)^n,t,x]

UniformP[n_]:=Sum[Binomial[n,k](x-k)^(n-1) (-1)^k Sign[x-k],{k,0,n}]/(n-1)!/2

Table[UniformP[n],{n,3}]//FullSimplify//ColumnForm//TraditionalForm

Table[UniformP[n],{n,5}]//ColumnForm//TraditionalForm

Table[UniformF[n],{n,5}]//ColumnForm//TraditionalForm

Simplify[Table[UniformF[n]-UniformP[n],{n,5}]]

<<Utilities`Typesetting`

MakeBoxes[ylabel[n_],TraditionalForm]:=RowBox[{SubscriptBox["P",RowBox[Flatten[{SubscriptBox["X","1"],Table[{"+",SubscriptBox["X",ToString[k]]},{k,2,n}]}]]],RowBox[{"","(","u",")"}]}]

Show[GraphicsArray[Block[{$DisplayFunction=Identity},
Table[
Plot[UniformP[n],{x,-.1,n+.1},
PlotStyle->Red,
PlotLabel->TraditionalForm[HoldForm[n]==n],
AxesLabel->TraditionalForm/@{u,ylabel[n]}
],{n,4}]]],GraphicsSpacing->-.1]

<<Statistics`DescriptiveStatistics`
<<Graphics`Graphics`

BarChart[BinCounts[data[1,100000],{0,1,.05}],PlotRange->All,BarSpacing->0]

BarChart[BinCounts[data[2,100000],{0,2,.05}],PlotRange->All,BarSpacing->0]

BarChart[BinCounts[data[3,100000],{0,3,.05}],PlotRange->All,BarSpacing->0]

BarChart[BinCounts[data[4,100000],{0,4,.05}],PlotRange->All,BarSpacing->0]

V7

Sum[Binomial[n,k](x-k)^(n-1) (-1)^k Sign[x-k],{k,0,n}]/(n-1)!/2

Sum[Binomial[n,k](x-k)^(n-1) (-1)^k Piecewise[{{x>k,1},{x<k,-1}},0],{k,0,n}]/(n-1)!/2

(1/(2(n-1)!))(Sum[Binomial[n,k](((x-k))^(n-1))(((-1))^k),{k,0,Floor[x]}]+Sum[Binomial[n,k](((x-k))^(n-1))(((-1))^k) ,{k,Floor[x]+1,n}])

Expected Number of Choices of x∈[0,1] to Get a Sum

(1/(n!))Sum[(((((-1))^k)n!(((n+1-k))^k))/(k!))(E^(n-k+1)),{k,0,n}]

P[n_,u_]:=(1/(2(n-1)!))Sum[(((-1))^k)Binomial[n,k](((u-k))^(n-1))Sign[u-k],{k,0,n}]

Table[(((((-1))^k)n!(((n+1-k))^k))/(k!)),{n,0,5},{k,0,n}]//ColumnForm

Plus@@@Table[(((((-1))^k)n!(((n+1-k))^k))/(k!))(E^(n-k+1)),{n,0,5},{k,0,n}]//ColumnForm//TraditionalForm

Expected Number of Choices of x∈[0,1] to Get a Sum >m

l=FullSimplify[Table[Integrate[P[n],{u,0,m},Assumptions->m>0],{n,5}],m>0]

Expected Number of Choices of x∈[0,1] to Get a Sum >1

Numerically to exceed 1

<<DiscreteMath`Combinatorica`

Mean[Table[Length[NestWhileList[#+Random[]&,0,#<1&]],{100000}]]-1.//Timing

Mean[Table[Length[NestWhileList[#+Random[]&,0,#<1&]],{10^6}]]-1.//Timing

Mean[Table[Length[NestWhileList[#+Random[]&,0,#<1&]],{10^7}]]-1.//Timing

data=Table[Length[NestWhileList[#+Random[]&,0,#<1&]],{10^6}]-1;//Timing

d=Distribution[data,Range[1,11]]

d/10^6.

Plus@@%

(d/10^5 ). Range[11]//N

Numerically to exceed 2

Mean[Table[Length[NestWhileList[#+RandomReal[]&,0,#<2&]],{(10^6)}]]-1.//Timing

Analytically

Table[Integrate[P[n,u],{u,0,1}],{n,5}]

Table[Integrate[P[n,u],{u,1,n}],{n,5}]

Table[1/n!,{n,5}]

Sum[(n/(n!)),{n,∞}]

Sum[n (1/(n(n-2)!)),{n,∞}]

Sum[(1/(n(n-2)!)),{n,∞}]

Expected Number of Choices of x∈[0,1] to Get a Sum >2

m2=Table[((2^(n-1))-n)/n! (n-2),{n,10}]

Through[{Numerator,Denominator}[m2]]

Sum[n (((n-2)((2^(n-1))-n))/(n!)),{n,∞}]