Closed juliusc closed 10 years ago
This is the correct behavior, as the hypothesis space here is not finite.
For instance, suppose that we are just sampling a single widget conditional on a threshold of 0.5. Inside next-good-widget
, we can get arbitrarily long sequences of widget draws with value less than the threshold. enumeration-query
searches in order and tries to exhaust these, but it obviously can't.
For better usability, we might want to detect when hypothesis spaces are infinite and complain. Even better (but harder) would be to accommodate some simple cases of infinite hypothesis spaces when the posterior support is finite (this likely requires constraint propagation, which no one has had the stomach to implement yet)
Aha, I didn't look carefully enough at that, and had not thought about these recursive functions.
Isn't detecting an infinite hypothesis space solving the halting problem?
There are broad classes where you can solve halting, though, (e.g., finite state machines, pushdown automata with finite resources)
There are indeed broad cases where detecting non-halting is possible (and where solving exact enumeration is still possible -- see cosh). But we aren't necessarily in those cases, so we can't detect in general. Detecting for specific cases is probably not worth it...
The following code gives a stack overflow error:
This is a modification of one of the probmods code examples, with rejection changed to enumeration. I've yet to investigate why this happens.