It was very hard not to wince when Donald Trump scored a solid laugh in his speech at the United Nations. Of course, this is partly because laughter isn’t commonly heard at the UN but is also because laughter is always meaningful to humans.

Part of the way humans respond to laughter is to work out whether we are included in it or excluded from it, and whether we are being laughed with or laughed at. I see people’s brains truly light up in the MRI scanner when they listen to laughter, as they’re trying to figure this all out.

And this matters to us because we’re social primates, and laughter is a social behaviour: we laugh to make and maintain social bonds, as well as to show the strength of our friendship with those we are laughing with.

As soon as there is a social bond formed between some people, however, it means that others have to be excluded from that group, and it can be exquisitely unpleasant to be excluded from laughter. It’s even more horrible if you realise that you are being laughed at by that same group of happy people. And it did feel like Donald Trump was being laughed at, not with.

Exactly how we feel about laughter will depend on precisely what we are doing – if I’m doing standup I don’t care if some of the laughter is directed at me, as I’m much more worried that there might be no laughter at all. Part of the reason standup is so stressful is that there is an immediate sign of whether it is working or not: the comic doesn’t want an audience silently thinking “that was funny” – they want to hear laughter. Learning to perform comedy involves learning to stop talking when you expect people to laugh, and to start talking again without sounding too anguished if they do not. If I am not doing standup, and I’m giving a serious science talk, then audience laughter can be extremely disconcerting.

Trump didn’t look like he was expecting a laugh when he boasted of his administration’s achievements: I suspect, if anything, he would have been anticipating delighted cheers. He tried to style it out, but it’s hard to escape the impression that his audience did not entirely share his sunny view of the successes of his administration. It’s interesting to me that they didn’t all think this silently, however: the fact that they felt like enough other people would share this view that they started to mark this with laughter is probably significant – the audience, at least, think something is wrong.

Laughter is a complex and highly ambiguous social signal. People will interpret laughter in a way that’s consistent with their interpretations of other people’s intentions. Trump may go away from this episode thinking: “Oh, help, they were laughing at me – perhaps no one likes me.”. But he might also think: “The audience are right: I am a very skilled and humorous speaker,” and feel like that’s what he intended all along. Mark Twain was right when he described laughter as a powerful weapon; but a powerful (if undeserved) sense of one’s own excellence is a good shield against this weapon.

• Sophie Scott is a senior fellow at University College London and an expert in cognitive neuroscience, particularly in relation to communications