Let \( x \) be the number of students initially in the class.
The total age of these \( x \) students is \( 18x \).
Let \( y \) be the number of students who join the class.
The total age of these \( y \) students is \( 16y \).
After the new students join, the total number of students is \( x + y \), and the total age is \( 18x + 16y \).
The new average age is 17, so we can set up the equation:
\[
\frac{18x + 16y}{x + y} = 17
\]
Multiplying both sides by \( x + y \), we get:
\[
18x + 16y = 17(x + y)
\]
Simplifying:
\[
18x + 16y = 17x + 17y
\]
\[
18x - 17x = 17y - 16y
\]
\[
x = y
\]
Thus, the ratio of the number of students who joined the class to the number of students initially in the class is \( \frac{y}{x} = \frac{2}{5} \).
Final Answer:
\[
\boxed{\frac{2}{5}}
\]