A reinforcement learning approach to cognitive radio