Code for amwt analysis