We show that the p-Selmer group of an elliptic curve is naturally the
intersection of two maximal isotropic subspaces in an infinite-dimensional
locally compact quadratic space over F_p. By modeling this intersection as the
intersection of a random maximal isotropic subspace with a fixed compact open
maximal isotropic subspace, we can explain the known phenomena regarding
distribution of Selmer ranks, such as the theorems of Heath-Brown and
Swinnerton-Dyer for 2-Selmer groups in certain families of quadratic twists,
and the average size of 2- and 3-Selmer groups as computed by Bhargava and
Shankar. The only distribution on Mordell-Weil ranks compatible with both our
random model and Delaunay's heuristics for Sha[p] is the distribution in which
50% of elliptic curves have rank 0, and 50% have rank 1. We generalize many of
our results to abelian varieties over global fields. Along the way, we also
give a formula for the self cup product on cohomology associated to the Weil
pairing.