In the present letter a method to find a proper expression for the force distribution inside a granular sample in static equilibrium is proposed. The method is based in statistical mechanics and the force distribution is obtained by studying how the potential elastic energy is divided among the different contacts between grains. It is found with DEM simulations with spheres that the elastic potential energy distribution follows a Bose Einstein law from which the force distribution is deduced. The present letter open a way in which granular materials can be studied with the tools provided by statistical mechanics.