Temperature is always the average of some quantity? I know that for an ideal gas it can be shown that the average kinetic energy can be written as:
$$\langle K\rangle= \dfrac{1}{2}k_B T.$$
Hence for an ideal gas, temperature can be identified with the average kinetic energy of the particles composing the system.
Now, of course not everything is an ideal gas. There are many other systems we deal in Statistical Mechanics like quantum gases, magnetic materials, and even black holes.
So, in the general case in Statistical Mechanics, is temperature the average of something? If that's true, what is temperature the average of?
EDIT: The point is that temperature is usually defined as
$$T = \dfrac{\partial U}{\partial S},$$
and this doesn't reflect that $T$ is the average of something. So, if $T$ is the average of something, what is this something and how does it connect to this definition?
The main point of the question is that thinking about something as the average of a certain quantity gives us better insight on that something. For instance, in the ideal gas case I presented, it allows us to justify thinking of $T$ as a measure of aggitation of the constituents of the system.
Now, I wanted to understand how we think of $T$ as an average in the general case - both classical and quantum mechanics with arbitrary system.
 A: Temperature has actually a very precise definition in Statistical Mechanics. If our system has energy $U$, entropy $S$ and $N$ degrees of freedom, we define the temperature $T$ such that $$\left(\frac{\partial S}{\partial U}\right)_{N}\equiv\frac{1}{T}.$$
The fact that for the kinetic model of the ideal gas we talk about temperature in terms of average energy comes from a result called the equipartition theorem, which states that for any degrees of freedom $x_n, x_m$ of a system in equilibrium with some reservoir at temperature $T$ (we call the description of this kind of system a canonical ensemble), we can write $$\left\langle x_n\frac{\partial H}{\partial x_m}\right\rangle=\delta_{mn}k_BT,$$
Where $H$ is the Hamiltonian of our system. Applying that to an ideal gas composed of $N$ particles of mass $m$, with momenta $p_i, i=1,2,... ,3N$, i.e. one momentum for each direction any particle can move at, we can write the hamiltonian of our system as (with implied summation): $$H=\frac{p_ip_i}{2m},$$ and therefore $$\left\langle p_i\frac{\partial H}{\partial p_j}\right\rangle=\left\langle p_i\frac{p_j}{m}\right\rangle=\delta_{ij}k_BT.$$
Looking only at $i=j$, we get that $$\left\langle \frac{p_i^2}{m}\right\rangle=k_BT.$$ Summing over the three dimensions of a single particle: $$\sum_{i=1}^{3}\left\langle \frac{p_i^2}{m}\right\rangle=2\langle K\rangle=3k_BT$$ $$\langle K\rangle=\frac{3}{2}k_BT,$$ which is the result we get from kinetic theory.
A: This is true of all macroscopic thermodynamic quantities, not just temperature - they're the average of some microscopic properties of the system. This is the fundamental connection between statistical mechanics and thermodynamics. This connection is the basis of the partition function formalism for doing statistical mechanics/thermodynamics. 
A: What temperature is fundamentally is a measure of the energy it would take to add to a reservoir at T to increase the number of states it has access to by a factor of e.  This fact can be seen from the "Boltzmann factor", e^(E/kT), which measures the ratio of the number of states available to the reservoir with and without extra energy E.  Thus, it's useful to realize that a temperature is really a property of a reservoir that a system is in contact with, either in reality or in our imagination-- we say a system is at T if no heat passes from a (possibly hypothetical) reservoir at T that the system could be brought into contact with.  All reservoirs at the same T also have no heat passing between them (that's the zeroth law of thermodynamics).  
By the way, although it doesn't matter, the average kinetic energy per particle is 3/2 kT, not 1/2 kT.
A: The expression $\langle K\rangle= \dfrac{3}{2}k_B T$ relates temperature to the average kinetic energy of an ideal gas particle. This generalizes poorly to other systems which are heterogeneous collections of particles, since it's unclear which set the corresponding average would be over. Consider a metal consisting of a vibrating ion lattice with an electron sea. Would your hypothetical generalization link $T$ to some average property of the electrons, or some average property of the ions?
One solution is to recognize that the kinetic energy of an ideal gas particle comes from three degrees of freedom (motion in the x,y,z directions). The three degrees of freedom share kinetic energy equally, so we can write: $\langle \frac{1}{2} m v_x^2 \rangle=\langle \frac{1}{2} m v_y^2 \rangle = \langle \frac{1}{2} m v_z^2 \rangle = \dfrac{1}{2}k_B T$. Now, the concept of degrees of freedom does generalize to other thermodynamic systems (at least classical ones). The generalization is given by the equipartition theorem that states $\left\langle x_n\frac{\partial H}{\partial x_m}\right\rangle=\delta_{mn}k_BT$, where $H$ is the Hamiltonian and the $x_i$ are generalized coordinates of the system. Gabriel Golfetti's answer goes into this in more detail.
If you want to include classical and quantum systems, you need a more radical generalization. The only one I can suggest is the relationship $T =  \dfrac{\partial U}{\partial S}$, where $U$ and $S$ are averages over the microstates making up a macrostate.
A: Short answer: no.
Extended answer: It depends on what you mean by temperature. If you restrict the concept of temperature to that macroscopic concept used in classical thermodynamics, then the answer is affirmative because the thermodynamic temperature $T$ is always the average of microscopic motions. For instance for ideal gas
$$ T \equiv \frac{2}{3 k_\mathrm{B} N} \langle K \rangle $$
But we can define a microscopic concept of temperature like
$$ T^\mathrm{micro} \equiv \frac{2}{3 k_\mathrm{B} N} K $$
This quantity is sometimes named the "instantaneous temperature", and it is not the average of anything. The usual thermodynamic temperature is the average of the microscopic temperature
$$ T = \langle T^\mathrm{micro} \rangle $$
A: As an answer, not to the original question but to the OP's comment to Gabriel Golfetti's answer

Thanks for the answer. That's a quite nice result, but when I read about it I got the impression that it is directly related to classical mechanics. Is there a quantum mechanical version of this?

there is also a quantum mechanical version of it, or rather two quantum mechanical versions, one for bosons (particle of integer spin) and one for fermions (particle of half-integer spin).
The calculation at the basis of Gabriel Golfetti's answer indeed uses the classical canonical ensemble, based on Maxwell–Boltzmann statistics .
But quantum particles obey different statistics.
Integer spin particles follow Bose–Einstein statistics, hence the name "bosons"
This, in particular, solves the "untraviolet catastrophe" mentioned by Gabriel Golfetti in his remark.
It is also the basis of superfluidity and superconductivity.
Half-integer spin particles follow Fermi-Dirac statistics, hence the name "fermions"
This provides the stability of matter. For instance, neutron stars resist the enormous pressure of their own gravitation because of Fermi-Dirac statistics. Only when their mass is large enough that even Fermi-Dirac statistics do not suffice to stabilise them do they collapse to black holes.
Essentially, the mean $$\left\langle x_n\frac{\partial H}{\partial x_m}\right\rangle$$ is definitely not $\delta_{mn}k_BT$ in general for either of these statistics.
It is however true that in "classical" situations, it becomes close to that value. But this means, in particular, that thermal radiation (for instance, old fashioned electric bulbs, unavailable in France now) is never "classical", since this is exactly the situation where Maxwell–Boltzmann statistics predicts the "ultraviolet catastrophe".
