The computation of electronic structures has recently become routine calculations in material science and chemistry. The dominating component
in such calculations is the SCF iterations, mainly because of the eigenvalue problem. We present a stochastic approach, where the electronic density
is formulated as a trace/diagonal of a matrix function, which is subsequently expressed as a statistical average. As a result, each SCF iteration only samples one random vector without having to compute all the orbitals. We present numerical results for both real-space and tight-binding discretizations. We also prove the convergence of the stochastic approach under mild conditions.