Let $s_k$ be the $k$-th parking space in a row of $g$ spaces $s_1, s_2, \ldots, s_{g-1}, s_g$. Point $g$ is the entrance of some crowded building, so the closer one is to $g$, the higher the probability of parking spots being occupied (the probability function will monotonically increase, but the formula is unknown).
(Note that the function above, $\frac{1}{1+e^{-(\frac{x}{4}-4)}}$, is illustrative and it is not the only one that satisfies the problem's requirements.)
Suppose a person wants to visit the building. This particular person is quite lazy and tries to minimize walking distance --- that is, parking the car as close to $g$ as possible. S/he advances forward, iterating over $k$, checking in each step if $s_k$ is free or not (so seeing the spots ahead is not an option). When finding a free space, the person must decide whether to park there or move on (advancing to $k+1$).
The optimal situation is to park on the closest-to-$g$ free space. The worst situation would be passing every free space, something undesirable for the driver, who prefers to play it safe: if the probability that $s_k$ is the last free parking space exceeds a certain threshold, s/he will park.
The individual's only source of information for making the forecast is occupation data of observed parking spots, which is recorded.
The person has travelled to spot $s_k$ (because of it, occupation data from $s_1$ to $s_k$ is available) and found it to be free. How could I go about calculating the probability of $s_k$ being the last space available for parking?