probmods / webchurch

A Church to Javascript compiler (DEPRECATED)
Other
140 stars 15 forks source link

multiple conditions at the end of query not implemented #65

Open feste opened 10 years ago

feste commented 10 years ago

Sorry, I should have put this issue up in webchurch instead of chapters...

When there are multiple conditions at the end of a query, the penultimate condition gets interpreted as the QUD rather than as an additional condition. (In the newest version of webchurch this is what happens. In the old (chapters) version, something else entirely happens that I don't quite understand.)

Here's a code example (In "Patterns of Inference" in chapters)

(define observed-luminance 3.0)

(define samples
(mh-query
1000 10

(define reflectance (gaussian 1 1))
(define illumination (gaussian 3 0.5))
(define luminance (* reflectance illumination))

reflectance

(condition (= luminance (gaussian observed-luminance 0.1)))
(condition (= illumination (gaussian 0.5  0.1)))))
(multiviz "Mean reflectance: " (mean samples)
(hist samples "Reflectance"))

If you replace the two conditions with "and" it gets interpreted correctly (although in this case, the probabilities are so low, I haven't gotten it to complete).