Equation of state of a classical anharmonic oscillator