There are more men in hard science and engineering and there are a variety of explanations for why, everything from the sexism notion, promoted by those in the social sciences, to the idea that the physical sciences and engineering don't seem directly related to helping people, which is an explanation offered by women who choose a life science or medicine. One odd notion, typified by prominent friend of Obama Dr. Larry Summers while he was at Harvard, was that women were not as good at math.

Tests added evidence to that idea but while No Child Left Behind was in force, its focus on math led to girls testing as well as boys in math for the first time ever, so it was not a capability issue. A scholar writing in Sex Roles finds that men overestimate their math ability while women view themselves accurately.  

Shane Bench of Washington State University conducted two tests with undergraduate students, one of 122 participants and the other 184. Each group first completed a math test before guessing how well they had fared at providing the right answers. In the first study, participants received feedback about their real test scores before they were again asked to take a test and predict their scores. In the second study, participants only wrote one test without receiving any feedback. They were, however, asked to report on their intent to pursue math-related courses and careers. 

Across the two studies it was found that men overestimated the number of problems they solved, while women quite accurately reported how well they fared. After the participants in Study 1 received feedback about their real test scores, the men were more accurate at estimating how well they had done on the second test. The results of Study 2 show that because the male participants believed they had a greater knack for maths than was the case, they were more likely to pursue maths courses and careers than women.

"Gender gaps in the science, technology, engineering and maths fields are not necessarily the result of women's underestimating their abilities, but rather may be due to men's overestimating their abilities," explains Bench. He and colleagues also found that women who had more positive past experiences with mathematics tended to rate their numerical abilities higher than they really were. This highlights the value of positively reinforcing a woman's knack for mathematics especially at a young age. 

"Despite assumptions that realism and objectivity are always best in evaluating the self and making decisions, positive illusions about math abilities may be beneficial to women pursuing math courses and careers. Such positive illusions could function to protect women's self-esteem despite lower-than-desired performance, leading women to continue to pursue courses in science, technology, engineering and maths fields and ultimately improve their skills."

Reference: Bench, S.W. et al (2015). Gender Gaps in Overestimation of Math Performance, Sex Roles. DOI 10.1007/s11199-015-0486-9