In this study, we propose and analyze a class of distributed algorithms performing the joint optimization of radio resources in heterogeneous cellular networks made of a juxtaposition of macro and small cells. Within this context, it is essential to use algorithms able to simultaneously solve the problems of channel selection, user association and power control. In such networks, the unpredictability of the cell and user patterns also requires distributed optimization schemes. The proposed method is inspired from statistical physics and based on the Gibbs sampler. It does not require the concavity/convexity, monotonicity or duality properties common to classical optimization problems. Besides, it supports discrete optimization which is especially useful to practical systems. We show that it can be implemented in a fully distributed way and nevertheless achieves system-wide optimality. We use simulation to compare this solution to today’s default operational methods in terms of both throughput and energy consumption. Finally, we address concrete issues for the implementation of this solution and analyze the overhead traffic required within the framework of 3GPP and femtocell standards.