4. As shown in Figure 5, positive real numbers $a_{1}, a_{2}, \cdots, a_{8}$ are marked at the corresponding vertices of a cube, such that the number at each vertex is the average of the three numbers marked at the adjacent vertices. Let
$$
\begin{array}{l}
M=\left(a_{1}+2 a_{2}+3 a_{3}+4 a_{4}\right) . \\
\quad\left(5 a_{5}+6 a_{6}+7 a_{7}+8 a_{8}\right), \\
N=a_{1}^{2}+a_{2}^{2}+\cdots+a_{8}^{2} . \\
\text { Then } \frac{M}{N}=
\end{array}
$$
4. $\frac{65}{2}$.

Assume that among the numbers marked in Figure 5, $a_{1}$ is the largest, then
$$
a_{1} \geqslant a_{2}, a_{1} \geqslant a_{4}, a_{1} \geqslant a_{5} .
$$

From $a_{1}=\frac{a_{2}+a_{4}+a_{5}}{3}$, we know
$$
\frac{a_{2}+a_{4}+a_{5}}{3} \leqslant a_{1} \text {. }
$$

The equality holds if and only if $a_{1}=a_{2}, a_{1}=a_{4}, a_{1}=a_{5}$, i.e., $a_{1}=a_{2}=a_{4}=a_{5}$ are all the largest.

Similarly, $a_{2}=a_{1}=a_{3}=a_{6}, a_{4}=a_{1}=a_{3}=a_{8}, a_{3}=a_{4}=a_{2}=a_{7}$, i.e.,
$$
a_{1}=a_{2}=\cdots=a_{8} .
$$

Therefore, $M=260 a_{1}^{2}, N=8 a_{1}^{2}$.