There is a clear association between musical ability and mathematical ability, perhaps best recognised in savantism in people with developmental disabilities. There are limited domains in which savantism appears to occur, including mathematical calculations, reproducing music instantly, recalling specific facts, and perfect-perspective drawing.
There are a number of psychological theories from this literature that tie maths and music as related abilities. One is the "male-brain" theory, which argues that male-brains are better at systemising (prediciting how systems work through rules) than empathising (predicting how people work through their emotions and thoughts), while female-brains work vice-versa (Baron-Cohen, 2002). Both music and maths are highly systemised, making them well-suited to "male-brained" individuals.
Another relevant theory is the "Central Coherence" theory, which again argues for different cognitive styles that may assist individuals to excel at both maths and music. Happe and Frith (2009) note that individuals with weak central coherence process information in fine detail, often at the expense of the greater context in which these details occur. This method of information processing may be beneficial to developing talents in both maths and music. The authors give the example of developing absolute pitch - a common ability in musical savants - as this requires attention to the exact notes rather than the relationship between notes.