Simulations for Top Down Model

Notes:
	- (Subscript[n, i]) is the branching factor at level i
	- ϵ is the total privacy budget and (Subscript[ϵ, i]) is the privacy budget at level i

2 Deep Hierarchy

Recreate Aloni’s 2 Deep Hierarchy with sliders for total epsilon and (Subscript[n, 2]).

Var[n2_, x_, eps_] := 2*(1/(n2^2 * x^2) + (n2 - 1)/(n2*(eps-x)^2))

Manipulate[Plot[Var[n2, x, eps], {x, 0, eps} , AxesLabel->{(Subscript[ϵ, 1]), "Var((Subscript[E, 1  j]))"}], {{n2, 10, (Subscript[n, 2])}, 1,20,Appearance->"Labeled"}, {{eps,4, ϵ}, 2,8,Appearance->"Labeled"}]

min= Function[{n, e}, Minimize[{Var[n, x, e], x ≥ 0 && x≤ e},x]]

Manipulate[Plot[Var[n2, x, eps], {x, 0, eps} ,Epilog->{Red,PointSize->Large,Point[{x /.Last[min[n2,eps]],First[min[n2,eps]]}]}, AxesLabel->{(Subscript[ϵ, 1]), "Var((Subscript[E, 1  j]))"}], {{n2, 10, (Subscript[n, 2])}, 1,20,Appearance->"Labeled"}, {{eps,4, ϵ}, 2,8,Appearance->"Labeled"}]

3 Deep Hierarchy

Questions:
	 - What is the shape of the variance plot as we vary (Subscript[ϵ, 1]), (Subscript[ϵ, 2]), and (Subscript[ϵ, 3])? 
	 - Error over 50% of bottom level units, with cancelation.

Var1j[n2_, e1_, e2_] = 2*(1/(n2^2 * e1^2) + (n2 - 1)/(n2*e2^2))

Var1jk[n2_,n3_, e1_, e2_,e3_] = 2*(1/(e3^2) + 1/(e3^2 * n3)) + (Var1j[n2, e1, e2] / n3^2)

Interactive Plot for variance on random variable of 3rd level of the hierarchy.   (Subscript[n, 3]) and the ratio between (Subscript[ϵ, 1]) and (Subscript[ϵ, 2]) have the most effect on the variance of (Subscript[ϵ, 3]).  (Subscript[n, 2])has a subtle effect on shape and ϵ adjusts scale.

Manipulate[ With[{e2share = 1 - e1share}, Plot[Var1jk[n2,n3, (1-e3)*e1share*eps ,(1-e3)*e2share*eps , e3*eps], {e3, 0, 1} , AxesLabel->{(Subscript[ϵ, 3]), "Var((Subscript[E, 1  jk]))"}]], {{n2, 10, (Subscript[n, 2])}, 1,20,1,Appearance->"Labeled"},{{n3, 10, (Subscript[n, 3])}, 1,20,1,Appearance->"Labeled"}, {{eps,4, ϵ}, 2,8,Appearance->"Labeled"}, {{e1share,0.5, (Subscript[ϵ, 1])/((Subscript[ϵ, 1])+(Subscript[ϵ, 2]))}, 0.0001,0.9999,Appearance->"Labeled"}]

Manipulate[  Plot[Var1jk[n2,n3, (1-e3)*e1share*eps ,(1-e3)*( 1 - e1share)*eps , e3*eps], {e1share, 0, 1} , AxesLabel->{(Subscript[ϵ, 1])/((Subscript[ϵ, 1])+(Subscript[ϵ, 2])), "Var((Subscript[E, 1  jk]))"}], {{n2, 10, (Subscript[n, 2])}, 1,20,1,Appearance->"Labeled"},{{n3, 10, (Subscript[n, 3])}, 1,20,1,Appearance->"Labeled"}, {{eps,4, ϵ}, 2,8,Appearance->"Labeled"}, {{e3,0.65, (Subscript[ϵ, 3])}, 0.0001,0.9999,Appearance->"Labeled"}]

Manipulate[ Plot[Var1j[n2, (1-e2)*eps , e2*eps], {e2, 0, 1} , AxesLabel->{(Subscript[ϵ, 2]), "Var((Subscript[E, 1  j]))"}], {{n2, 10, (Subscript[n, 2])}, 1,20,1,Appearance->"Labeled"}, {{eps,4, ϵ}, 2,8,Appearance->"Labeled"}]

Error in “District” composed of half the bottom-level

SampleE1j[e1_,e2_, n2_] := With[ {L1 = LaplaceDistribution[0, 1/e1], L2 =  LaplaceDistribution[0, 1/e2] }, RandomVariate[L1]/ n2 + RandomVariate[L2] -  Total[RandomVariate[ProductDistribution[{L2, n2}]]]]

SampleE1jk[e1_,e2_,e3_, n2_, n3_] := With[{L1 = LaplaceDistribution[0, 1/e1], L2 =  LaplaceDistribution[0, 1/e2], L3 = LaplaceDistribution[0, 1/e3]},RandomVariate[L3] + (-Total[RandomVariate[ProductDistribution[{L3, n3}]]] + SampleE1j[e1, e2, n2])/n3]

Manipulate[ 
sample = Array[Function[b, Total[Array[Function[a, SampleE1jk[e1*eps, e2*eps,(1- e1 - e2)*eps, n2,n3]], Round[(n2*n3)/k]]]],500];
Show[Histogram[sample, Automatic, "PDF", AxesLabel->{(Subscript["E", 3,(Subscript[dist, k])])}],SmoothHistogram[sample]],{{k, 2, k}, 2,10,1,Appearance->"Labeled"}, {{n2, 4, (Subscript[n, 2])}, 1,10,1,Appearance->"Labeled"},{{n3, 4, (Subscript[n, 3])}, 1,10,1,Appearance->"Labeled"}, {{eps,4, ϵ}, 2,8,Appearance->"Labeled"}, {{e1,0.25, (Subscript[ϵ, 1])}, 0.001,1-e2,Appearance->"Labeled"},{{e2,0.25, (Subscript[ϵ, 2])}, 0.001,1 - e1,Appearance->"Labeled"}, ContinuousAction->False]

With[{n2=5, n3=4, eps=4, e1=0.25, e2=0.25}, 
data = Array[Function[b, Total[Array[Function[a, SampleE1jk[e1*eps, e2*eps,(1- e1 - e2)*eps, n2,n3]], Round[(n2*n3)/2]]]],10000];Show[Histogram[data, Automatic, "PDF", AxesLabel->{"(Subscript[E, 3, dist])"}],SmoothHistogram[data]]]

With[{n2=5, n3=4, eps=4, e1=0.25, e2=0.25}, 
data = Array[Function[b, Total[Array[Function[a, SampleE1jk[e1*eps, e2*eps,(1- e1 - e2)*eps, n2,n3]], Round[(n2*n3)/4]]]],10000];Show[Histogram[data, Automatic, "PDF", AxesLabel->{"(Subscript[E, 3, dist])"}],SmoothHistogram[data]]]

Error at one instance at third level

Manipulate[ Histogram[Array[Function[b,SampleE1jk[e1*eps, e2*eps,(1- e1 - e2)*eps, n2,n3]], 500],AxesLabel->{"(Subscript[E, 1  jk])"}], {{n2, 4, (Subscript[n, 2])}, 1,10,1,Appearance->"Labeled"},{{n3, 4, (Subscript[n, 3])}, 1,10,1,Appearance->"Labeled"}, {{eps,4, ϵ}, 2,8,Appearance->"Labeled"}, {{e1,0.25, (Subscript[ϵ, 1])}, 0.001,1-e2,Appearance->"Labeled"},{{e2,0.25, (Subscript[ϵ, 2])}, 0.001,1 - e1,Appearance->"Labeled"}, ContinuousAction->False]

3

Absolute Error

L1 = LaplaceDistribution[0, 1/e1]

L2 = LaplaceDistribution[0, 1/e2]

Manipulate[ex = Expectation[Abs[x + n2*y - Module[{k},Sum[(Subscript[x, k]),{k,1,n2}]]/n2], {x\[Distributed] L1, y \[Distributed] L2, Reduce`FreeVariables[Module[{k},Sum[(Subscript[x, k]),{k,1,n2}]]] \[Distributed]ProductDistribution[{L2, n2}]}];  Plot[(ex/ n2) /. {e2 -> 1- e1}, {e1, 0, 1},AxesLabel->{(Subscript[ϵ, 2]), (Subscript["|(Subscript[E, 1  j])|", n2])}],{{n2, 2, (Subscript[n, 2])}, 1,10,1,Appearance->"Labeled"}]

Expectation[Abs[x + y], {x\[Distributed] L1, y \[Distributed] L2}]

Variance at level l

Variance at level l, with fixed branching constant, and equal split between lower level epsilons.
Something is off in these equations.  It doesn’t match the level 2 and 3 variance plots even with the same parameters.  See plots of VarEh(2, ...) and Var1j below

VarEh [l_, ns_, es_] := 1/ns[[l]]^2 * (2/es[[1]]^2 * 1/(Times@@Drop[ns,-1]) + Sum[Product[1/ns[[k]]^2, {k, j+1, l-1}], {j, 2, l-1}] ) + (1  - 1/ns[[l]])*2/es[[l]]^2
(*Sum[(1- 1/ns[[l-j]])*(2/es[[l-j]]^2)*Product[1/ns[[l-k]]^2, {k, 0 , j-1}], {j, 0, l-1}]*)

Plot[VarEh[2, {1,10}, {1-e2, e2}], {e2, 0, 1}]

VarEh[3, {1,10,10},{1-e2-e3, e2, e3}]

Reduce[ 0 < e2 < 1 && 0 < e3 < 1 && 0 < 1 - e2  - e3  < 1, {e2, e3}]

Manipulate[Plot3D[VarEh[3, {1,n2,n3},{(1-e2-e3)*4, e2*4, e3*4}], {e2, 0, 1}, {e3, 0, 1}, AxesLabel->{"e2", "e3", "Var((Subscript[E, 1  jk]))"},Mesh->False,
RegionFunction->Function[{e2, e3}, 0 < e2 < 1 && 0 < e3 < 1 && 0 < 1 - e2  - e3  < 1]], {{n2, 10, (Subscript[n, 2])}, 1,20,1,Appearance->"Labeled"},{{n3, 10, (Subscript[n, 3])}, 1,20,1,Appearance->"Labeled"}]

Plot3D[VarEh[2, {1,n2}, {(1-e2)*4, e2*4}], {e2, 0, 1}, {n2, 1,30 }, AxesLabel->{"(Subscript[e, 2])", "(Subscript[n, 2])", "Var((Subscript[E, 1  j]))"}]

Plot3D[VarEh[3, {1,10,10}, {(1-e3)*e1share*4 ,(1-e3)*4*(1 - e1share) , e3}*4], {e3, 0, 1} ,{e1share, 0, 1},  AxesLabel->{(Subscript[ϵ, 3]),(Subscript[ϵ, 1])/((Subscript[ϵ, 1])+(Subscript[ϵ, 2])), "Var((Subscript[E, 1  jk]))"}]

Plot3D[VarEh[3, {1,3,10},{(1-e2-e3)*4, e2*4, e3*4}], {e2, 0, 1}, {e3, 0, 1}, AxesLabel->{"(Subscript[e, 2])", "(Subscript[e, 3])", "Var((Subscript[E, 1  jk]))"},
RegionFunction->Function[{ e2, e3}, 0 < e2 < 1 && 0 < e3 < 1 && 0 < 1 - e2  - e3  < 1]]

Manipulate[Plot[VarEh[l, n, el*eps, (1-el)*eps/(l-1)], {el, 0,1}, AxesLabel->{(Subscript[ϵ, l]), "Var((Subscript[E, h]))"}], {{l, 3, l}, 2,10,1,Appearance->"Labeled"},{{n, 10, n}, 1,20,1,Appearance->"Labeled"},{{nl, 10, nl}, 1,20,1,Appearance->"Labeled"}, {{eps,4, ϵ}, 1,8,Appearance->"Labeled"}]

Plot[VarEh[2, {1,10}, {1-e2, e2}], {e2, 0, 1}, PlotLabel->VarEh[2, {1,10}, {1-e2, e2}]]

Plot[Var1j[10, 1-el, el], {el, 0, 1},PlotLabel->Var1j[10, 1-e2, e2]]

VarEh[2, {1,10}, {1-e2, e2}]

Var1j[10, 1-e2, e2]

VarEh[2, {1,10}, {1-e2, e2}]

VarEh[1, {1,10}, {e2, e2}]

Plot[VarEh[3, {1,10,10}, {(1-e3)/2,(1-e3)/2, e3}], {e3, 0, 1}, PlotLabel->VarEh[3, {1,10,10}, {(1-e3)/2,(1-e3)/2, e3}]]

Var1jk[10,10, (1-e3)/2,(1-e3)/2, e3]

Plot[Var1jk[10,10, (1-e3)/2,(1-e3)/2, e3], {e3, 0, 1}, PlotLabel->Var1jk[10,10, (1-e3)/2,(1-e3)/2, e3]]