We show that for a large class of rings R, the number of principally polarized abelian varieties over a finite field in a given simple ordinary isogeny class and with endomorphism ring R is equal either to 0, or to a ratio of class numbers associated to R, up to some small computable factors. This class of rings includes the maximal order of the CM field K associated to the isogeny class (for which the result was already known), as well as the order R generated over Z by Frobenius and Verschiebung.
For this latter order, we can use results of Louboutin to estimate the appropriate ratio of class numbers in terms of the size of the base field and the Frobenius angles of the isogeny class. The error terms in our estimates are quite large, but the trigonometric terms in the estimate are suggestive: Combined with a result of Vlăduţ on the distribution of Frobenius angles of isogeny classes, they give a heuristic argument in support of the theorem of Katz and Sarnak on the limiting distribution of the multiset of Frobenius angles for principally polarized abelian varieties of a fixed dimension over finite fields.
This paper had a very long gestation period. I worked out some of the math at the turn of the last century, and I first wrote about the work (as far as I can determine) in an email to Nick Katz in October 2000. (The email is available here.) I shared that email with a number of researchers over the years, and gave quite a few talks about the mathematics involved (AGCT-8 in Luminy, May 2003; AMS Sectional Meeting, San Francisco, May 2003; Arizona State, Tucson, March 2004; Universitat Politècnica de Catalunya, Barcelona, March 2004; Front Range Number Theory Seminar, Boulder, CO, December 2006; … ; ICERM, Providence, RI 2019), but my conception of the work was primarily as a heuristic explanation of the Katz–Sarnak result, and I could not figure out how to fit this into a math paper with theorems. Jeff Achter, at Colorado State, had encouraged me over the years to write something down, and in 2018 I finally had a draft. Jeff had some good criticisms of that version, and it took a couple more years before I could finally sit down and rewrite the paper.
Twenty years is definitely a personal record for the longest time between thinking of some math and submitting a paper.