Yao's correlation function code