Search code examples
probabilityinferencewebppl

WebPPL: return just one result


i have the following :

var rand = Infer({method: 'enumerate'}, function() {
    var A = randomInteger({n: 4})
    var B = randomInteger({n: 4})
    condition(A == B)
    return {A:A, B:B}
})


$ webppl test.wppl 
Marginal:
    {"A":3,"B":3} : 0.25
    {"A":2,"B":2} : 0.25
    {"A":1,"B":1} : 0.25
    {"A":0,"B":0} : 0.25

I want to test n > 1000, but i will get > 1000 lines result.

What should i use as return to get back just one result f.e.

    {"A":_,"B":_} : 0.25

Solution

  • this works, but seems hacky

    condition(A == B)
    return A == 1 ? {A:A, B:B} : 'rest'