function[UDmax,UDmaxcrit]=h2csd_gen_det(N,T,y,x,w,db,dnb,p,q,M,tr,phi)
for b=1:M
    [supF(b,1)]=h1ucsd_gen_det(N,T,b,p,q,y,x,w,db,dnb,tr,phi);
end
[UDmax,~]=max(supF);
UDmaxcrit=13.27;
%crit value depends on q and trim. The above is for q=2, trim=0.05