added version that uses n=1 for calculating expectation value