
Is the "Embedded domain-specific language HANSEI for probabilistic models and (nested) inference" described in: http://okmij.org/ftp/kakuritu/index.html#implementation available in Haskell? Is there a reason why the author did the package in Ocaml rather than Haskell? -- Daryoush

Hello! Thank you for your interest.
Daryoush Mehrtash
Is the "Embedded domain-specific language HANSEI for probabilistic models and (nested) inference" described in: http://okmij.org/ftp/kakuritu/index.html#implementation available in Haskell?
The closest to that I know of is this one: http://d.hatena.ne.jp/rst76/20100706 https://github.com/rst76/probability Or you can apply this monad transformer to a probability monad: http://sebfisch.github.com/explicit-sharing/
Is there a reason why the author did the package in Ocaml rather than Haskell?
Mostly we preferred (as do the domain experts we target) to write probabilistic models in direct style rather than monadic style. Haskell's laziness doesn't help -- in fact, to avoid running out of memory, we'd have to defeat that memoization by sprinkling "() ->" throughout the types. -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig 1st graffitiist: QUESTION AUTHORITY! 2nd graffitiist: Why?

I would very much appreciate if you can expand on this: Haskell's laziness doesn't help -- in fact, to avoid running out of
memory, we'd have to defeat that memoization by sprinkling "() ->"
throughout the types.
Would it be possible to explain this with an example?
Thanks
Daryoush
On Wed, Feb 23, 2011 at 7:52 AM, Chung-chieh Shan
Hello! Thank you for your interest.
Daryoush Mehrtash
wrote in haskell-cafe: Is the "Embedded domain-specific language HANSEI for probabilistic models and (nested) inference" described in: http://okmij.org/ftp/kakuritu/index.html#implementation available in Haskell?
The closest to that I know of is this one: http://d.hatena.ne.jp/rst76/20100706 https://github.com/rst76/probability
Or you can apply this monad transformer to a probability monad: http://sebfisch.github.com/explicit-sharing/
Is there a reason why the author did the package in Ocaml rather than Haskell?
Mostly we preferred (as do the domain experts we target) to write probabilistic models in direct style rather than monadic style. Haskell's laziness doesn't help -- in fact, to avoid running out of memory, we'd have to defeat that memoization by sprinkling "() ->" throughout the types.
-- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig 1st http://www.digitas.harvard.edu/cgi-bin/ken/sig1st graffitiist: QUESTION AUTHORITY! 2nd graffitiist: Why?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Wed, Feb 23, 2011 at 10:52 AM, Chung-chieh Shan
Mostly we preferred (as do the domain experts we target) to write probabilistic models in direct style rather than monadic style. Haskell's laziness doesn't help -- in fact, to avoid running out of memory, we'd have to defeat that memoization by sprinkling "() ->" throughout the types.
I don't think that "() ->" is even guaranteed to work...

Leon Smith
On Wed, Feb 23, 2011 at 10:52 AM, Chung-chieh Shan
wrote: Mostly we preferred (as do the domain experts we target) to write probabilistic models in direct style rather than monadic style. Haskell's laziness doesn't help -- in fact, to avoid running out of memory, we'd have to defeat that memoization by sprinkling "() ->" throughout the types. I don't think that "() ->" is even guaranteed to work...
That's quite true. Then again, it's not guaranteed that "() ->" is needed for good memory usage. We just need a sufficiently smart compiler! -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig 1st graffitiist: QUESTION AUTHORITY! 2nd graffitiist: Why?

I am confused about this comment:
Mostly we preferred (as do the domain experts we target) to write
probabilistic models in direct style rather than monadic
In the haskell implementation of the lawn model there are two different
version of the grassModel (
https://github.com/rst76/probability/blob/master/src/Lawn.hs)
grassModel :: PM Bool
grassModel =
let_ (flip_ 0.3) (\ rain ->
let_ (flip_ 0.5) (\ sprinkler ->
let_ (dis (con (flip_ 0.9) rain)
(dis (con (flip_ 0.8) sprinkler)
(flip_ 0.1))) (\ grassIsWet ->
if_ grassIsWet rain (dist []))))
and
grassModel = do
rain <- flip_ 0.3
sprinkler <- flip_ 0.5
wetInRain <- flip_ 0.9
wetInSprinkler <- flip_ 0.8
wetInOther <- flip_ 0.1
let grassIsWet = rain && wetInRain
|| sprinkler && wetInSprinkler
|| wetInOther
if grassIsWet then return rain else dist []
By domain expert preferring direct style do you mean that they prefer
the first version over the 2nd version?
thanks,
Daryoush
On Wed, Feb 23, 2011 at 7:52 AM, Chung-chieh Shan
Hello! Thank you for your interest.
Daryoush Mehrtash
wrote in haskell-cafe: Is the "Embedded domain-specific language HANSEI for probabilistic models and (nested) inference" described in: http://okmij.org/ftp/kakuritu/index.html#implementation available in Haskell?
The closest to that I know of is this one: http://d.hatena.ne.jp/rst76/20100706 https://github.com/rst76/probability
Or you can apply this monad transformer to a probability monad: http://sebfisch.github.com/explicit-sharing/
Is there a reason why the author did the package in Ocaml rather than Haskell?
Mostly we preferred (as do the domain experts we target) to write probabilistic models in direct style rather than monadic style. Haskell's laziness doesn't help -- in fact, to avoid running out of memory, we'd have to defeat that memoization by sprinkling "() ->" throughout the types.
-- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig 1st graffitiist: QUESTION AUTHORITY! 2nd graffitiist: Why?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Daryoush Weblog: http://onfp.blogspot.com/

Daryoush Mehrtash
I am confused about this comment:
Mostly we preferred (as do the domain experts we target) to write probabilistic models in direct style rather than monadic
In the haskell implementation of the lawn model there are two different version of the grassModel ( https://github.com/rst76/probability/blob/master/src/Lawn.hs)... By domain expert preferring direct style do you mean that they prefer the first version over the 2nd version?
No, there is no way to write probabilistic models in direct style in Haskell, and domain experts prefer neither Haskell version you showed. A symptom of direct style is being able to write something like flip 0.3 && flip 0.5 where (&&) takes two Bool arguments. -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig 1st graffitiist: QUESTION AUTHORITY! 2nd graffitiist: Why?

I see the problem now. But I am confused as to why there are no Bool class
(like Num, Fractional...) in Haskell. If I had such a class then the
problem is solved, (by making the "pm a" an instance of it) right? Or are
there still more issues that I am not seeing?
thanks,
daryoush
On Mon, Feb 28, 2011 at 7:34 AM, Chung-chieh Shan
Daryoush Mehrtash
wrote in haskell-cafe: I am confused about this comment:
Mostly we preferred (as do the domain experts we target) to write probabilistic models in direct style rather than monadic
In the haskell implementation of the lawn model there are two different version of the grassModel ( https://github.com/rst76/probability/blob/master/src/Lawn.hs)... By domain expert preferring direct style do you mean that they prefer the first version over the 2nd version?
No, there is no way to write probabilistic models in direct style in Haskell, and domain experts prefer neither Haskell version you showed.
A symptom of direct style is being able to write something like
flip 0.3 && flip 0.5
where (&&) takes two Bool arguments.
-- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig 1st graffitiist: QUESTION AUTHORITY! 2nd graffitiist: Why?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Daryoush Weblog: http://onfp.blogspot.com/

Daryoush Mehrtash
I see the problem now. But I am confused as to why there are no Bool class (like Num, Fractional...) in Haskell. If I had such a class then the problem is solved, (by making the "pm a" an instance of it) right? Or are there still more issues that I am not seeing?
Sorry, I gave a bad example. Here are two more general symptoms of direct style: being able to write something like f (if flip 0.3 then LT else EQ) where f is an existing function that takes an Ordering argument, and even being able to write something like and (map flip [0.3, 0.5]) where and :: [Bool] -> Bool map :: (a -> b) -> [a] -> [b] are existing functions. -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig 1st graffitiist: QUESTION AUTHORITY! 2nd graffitiist: Why?
participants (3)
-
Chung-chieh Shan
-
Daryoush Mehrtash
-
Leon Smith