Baby shaking head?

My 7 month old son has started doing something peculiar. There’s no rhyme or rhythm to it, it’s all spontaneous. What he does is, he will shake his head back and fourth like he’s saying no. He doesn’t do it hard enough where he’s hurting himself. It’s just like he’s saying that he doesn’t want or like something. The weird thing is, I haven’t asked him anything, so it’s not like he’s answering a question. He does it either laying down or when I sit him up. Sometimes when he’s on all fours. And it’s all out of the blue. The only time I’ve seen him do this on purpose is when he’s tired and he’ll rub his face on his hands or in my shoulder. Anybody know why?