MInimal Distence index for the data with one feature

Input: partition Π={(Subscript[π, 1]),⃛,(Subscript[π, k])} of the set 𝒜 ⊂ (ℝ^n);
Output: MD1 -index;
Submodules:  WF[]

Clear[MMD]
(* Minimal distance index for the data with one feature *)
MD1[PI_,p_,Ind_]:=Module[{n=1,m=Length[Flatten[PI,1]],k=Length[PI],z,q,edge,dist},
z=q=edge=Table[0,{j,Length[PI]}];
dist=Table[0,{j,Length[PI]-1}];
Do[j1=Length[PI]-j+1;
z[[j]]=Mean[PI[[j,All,2]]]; 
q[[j1]]=Quantile[Abs[PI[[j,All,2]]-z[[j]]],p] ;
,{j,Length[PI]}];
If[Ind≠0,Print["z=",z,"\nq=",Round[q,-.01],";  p=",p]];
Do[j1=Length[PI]-j+1;
edge[[j]]={Max[z[[j]]-q[[j]],Min[PI[[j,All,2]]]],Min[z[[j]]+q[[j]],Max[PI[[j,All,2]]]]};
If[Ind≠0,Print[j," edge; ",edge[[j]]]];
,{j,Length[PI]}];
Do[j1=Length[PI]-j+1;
dist[[j]]=edge[[j,1]]-edge[[j+1,2]];
If[Ind≠0,Print[j,";  dist=",dist[[j]]]];
,{j,Length[PI]-1}];
{(m-Length[PI])Min[dist]/WF[PI],q,edge,dist}
]

Example