  We prove an asymptotic formula for the number of ${\rm SL}_3({\mathbb
Z})$-equivalence classes of integral ternary cubic forms having bounded
invariants. We use this result to show that the average size of the 3-Selmer
group of all elliptic curves, when ordered by height, is 4. This implies that
the average rank of all elliptic curves, when ordered by height, is less than
1.17.
  Combining our counting techniques with a recent result of Dokchitser and
Dokchitser, we prove that a positive proportion of all elliptic curves have
rank 0. Assuming the finiteness of the Tate-Shafarevich group, we also show
that a positive proportion of elliptic curves have rank 1. Finally, combining
our counting results with the recent work of Skinner and Urban, we show that a
positive proportion of elliptic curves have analytic rank 0; i.e., a positive
proportion of elliptic curves have non-vanishing $L$-function at $s=1$. It
follows that a positive proportion of all elliptic curves satisfy BSD.
