How does the Teacher Know when to Appear?

It has been frequently said that when the student is ready, the teacher appears. Experience shows that this is true in many ways. But how does the teacher know the right moment to appear?  Who tells the teacher that the student is ready? And how does the teacher “appear” out of thin air? The fact is…