%cont continouous moment from discrete moments

my_wav = 'Bior1.3';
MAXMOMENT=6
[Lo_D,Hi_D,Lo_R,Hi_R] = wfilters(my_wav)

dsc_mom=zeros(1,MAXMOMENT);
dw_mom=zeros(1,MAXMOMENT);

for k=0:MAXMOMENT-1
    for i=1:length(Lo_D)
       % dsc_mom(k+1)=dsc_mom(k+1)+(i-1)^k*Lo_D(i);
      dsc_mom(k+1)=dsc_mom(k+1)+(i-1)^k*Lo_R(i);       
    end
   for i=1:length(Hi_D)
      dw_mom(k+1)=dw_mom(k+1)+(i-1)^k*-Hi_R(i);
   end
end
dsc_mom
dw_mom

%and now try continuous moments

csc_mom=zeros(1,MAXMOMENT);
cw_mom=zeros(1,MAXMOMENT);
csc_mom(1)=1;

for k=1:MAXMOMENT-1
   for l=1:k
       csc_mom(k+1)=csc_mom(k+1) +  nchoosek(k,l)*dsc_mom(l+1)*csc_mom(k-l+1);
    end    
   csc_mom(k+1)=csc_mom(k+1)/((2^k-1)*2^0.5);
end
for k=1:MAXMOMENT-1
   for l=0:k
       cw_mom(k+1)=cw_mom(k+1) +    nchoosek(k,l)*dw_mom(l+1)*csc_mom(k-l+1);
    end    
   cw_mom(k+1)=cw_mom(k+1)/2^(k+0.5);
end

csc_mom
cw_mom