added comments and simplified calculate_triplet_PD()