probmods/webppl — pull request #14 by bessiambre (2014-09-30 00:40:24+00:00)
Title: issue with MH when there is no return value

Hi,

First, I want to say that my mind is completely blown by probabilistic programming languages. This implementation is incredibly clever while still clean and relatively simple. Thank you for making it open source and accessible to non experts enthusiasts like myself.

While playing with the computer vision example, I wanted to try 'Inferring lines that match the target image' but using MH instead of ParticleFilter. However, I was just getting random output.

Using the chrome debugger I was able to hunt down the problem to a requirement that MH input functions return something. This is due to the line:

acceptance = coroutine.oldVal==undefined ?1:acceptance //just for init

I was able to make the vision example work using

MH(
function(){
var lines = makeLines(4, [], 0);
var finalGeneratedImage = Draw(50, 50, true);
drawLines(finalGeneratedImage, lines);
return 0;
}, 100)

This is my attempt at fixing the problem. I may be out to lunch as a lot of this is quite over my head. Please disregard this pull request if so. I verified that ./run-tests still passes but didn't get as far as testing in the book. This is my first pull request. I hope I am using Github correctly.

Note that I removed findChoice() and MHacceptProb() duplicates in header.js.

You guys are doing amazing work. cheers.