I do ok at big-O reasoning, but in this case turning probabilities into big-O eludes me.
In the video, there's an opposite maze which biases the guests to walk towards the exit, making it much easier to solve. What's the big-O of that version?
State (0, *) transitions to (1, forwards)
For k > 1, state (k, forwards) transitions to (k+1, forwards) with 5/8 probability and to (k-1, backwards) with probability 3/8.
For k > 1, state (k, backwards) transitions to (k+1, forwards) with 1/8 probability and to (k-1, backwards) with probability 7/8.
My intuition is that this very much resembles a biased walk so it should take exponential time. But there is the "momentum" to take into account.
Edit: It looks like we can use https://en.wikipedia.org/wiki/Absorbing_Markov_chain#Expecte...
Your vertices would be (x, y, f), f being facing.
Edges are along the lines of (x, y, 0) - (x+1, y, {0,1,2,3}\1); (x, y, 1) - (x-1, y, {0,1,2,3}\0); (x, y, 2) - (x, y+1, {0,1,2,3}\3); (x, y, 3) - (x, y-1, {0,1,2,3}\2).
Probabilities are modeled in the video and need to be rotated 4 times for the four facings.
After that, I just don't recall my eigenvector calculation anymore. It feels like a good markov exercise, though.
I would argue using Big O here is wrong and Landau symbols are not well defined on Markov chains/probabilistic turing machines. The point of Landau symbols is to give asymptotic bounds of functions with N approaching a certain value (usually positive infinity). My intuition says that the runtime of a probabilistic turing machine isn't necessarily a function tho (i.e. a deterministic association between any N and time(N)).
Google wasn't really helpful on complexity theory of Markov chains and based on the research papers that pop up it seems far enough away that I would avoid using Big O in this scenario.
Probabilistic turing machines even seem to have their own complexity classes (https://en.m.wikipedia.org/wiki/Probabilistic_Turing_machine).
- only the most significant (in terms of exponentially) factor(s) matters for big O (i.e. if you have a linear factor, the constant time factor is ignored)
- You have to determine whether you are talking worst case or average case or best case. Assuming average case I’d guess the opposite maze is O(n) because the time expands linearly with number of segments.
(Disclaimer: I am not formally educated in computer science, so admittedly I am not up to snuff on the mathematical side of things. Hopefully I am close enough here.)
edit: Oops, I failed to actually cover any time complexity calculation at all. I do not know if my approach is correct, but here's how I view the original:
def walk_path(n):
// probability of _not_ recursing is (1/n^2)
// probability of _recursing_ is (1 - 1/n^2)
// likelihood of recursing doubles with n
// therefore, the average case of this loop is O(2^n)
for (i : 0 -> n)
if (random() < 0.5)
walk(); // = O(1)
else
// Ignoring the actual walking on the branch, we just pretend we turn around directly.
for (j : i -> 0) // = O(n/2)
walk();
return walk_path(n);
and the opposite is straight forward, since the branches are 'constant time' - so it's more like a straight loop.Worst case is infinite: you just always take the path back in the direction of the entrance, and never even get past the first inlet.
Best case is O(n): you always take the path forward.
The measured values are empirically exponential with a factor of 1.424 per indentation. If we assume that as an upper bound (which I don't think is quite right), then we have O(1.424^N) where N is the number of indentations.
Any exponent can be written in terms of any other base by multiplying by a constant. Since we often use base 2, we can choose to rewrite it in base 2 as O(2^(K*N)), where K is approximately 0.51.
Constant terms can be ignored in big O notation, so we can just drop the K to get O(2^N) (I am less sure about dropping a constant within the exponent).
Related: https://en.wikipedia.org/wiki/Big_O_notation#Multiple_uses
The devs have since updated the game to remove the clockwise bias.