What is the expected number of turns of a randomly-chosen 9-step path from POINT A to POINT B.

545 Views Asked by At

(A turn is any point where the path changes its direction ; for example path shown has 3 turns.) I have written a code to analyse any pattern. I am focussing on smaller things and losing the bigger picture. Is there a way, we can solve the given picture in mind.

Here is the code to print expected values (https://ide.geeksforgeeks.org/WqafdrG7m7)

See Image for reference]1

2

There are 2 best solutions below

0
On BEST ANSWER

Start with five $1$'s (corresponding with steps to the right) and with four $0$'s (corresponding with steps upwards).

Then the sequence corresponding with your example will be $110001110$.

We are interested in the expectation of the number of subwords of the form $01$ or $10$.

This expectation equals: $$\frac{2\times5\times4}{5+4}=\frac{40}{9}$$

or in a more general form:$$\frac{2ru}{r+u}$$where $r$ denotes the number of $1$'s and $u$ the number of $0$'s.

Have a look at this question and its answers to find out why.

0
On

Treat point $A$ as $(0,0)$ on a Euclidean plane. Then, point $B$ is located at $(5,4)$. The first move never results in a turn. Thereafter, $x$ and $y$ may be incremented up to $x=5$ and $y=4$. If an increment to $x$ is performed, then a turn is made where the previous increment was to $y$, and vice versa. Otherwise an increment does not result in a turn.

Then, use the two starting conditions $(1,0)$ and $(0,1)$ combine the first step for $x$ and $y$ if you want. Simulate each possible path. Use the number of turns and the number of possible paths to determine the expected value.

I hope that helps!