Automatically estimate the sample period