Experimentally measuring the purity of a state without state tomography