[Haskell-cafe] Monads with "The" contexts?

Takayuki Muranushi muranushi at gmail.com
Sat Jul 21 18:34:44 CEST 2012

Dear Oleg,

You're right. The points boil down to
> That assumption (that the deviations are small) is not stated in types and it is hard to see how can we enforce it.
and even if it's small, there's corner cases at df/dx = 0 or df/dx =
infinity (as you have mentioned.)

Thanks to your advices, I'll look for other ways to set up
probabilistic computations.

2012/7/19  <oleg at okmij.org>:
>> http://en.pk.paraiso-lang.org/Haskell/Monad-Gaussian
>> What do you think? Will this be a good approach or bad?
> I don't think it is a Monad (or even restricted monad, see
> below). Suppose G a is a `Gaussian' monad and n :: G Double is a
> random number with the Gaussian (Normal distribution).  Then
>         (\x -> x * x) `fmap` n
> is a random number with the chi-square distribution (of
> the degree of freedom 1). Chi-square is _not_ a normal
> distribution. Perhaps a different example is clearer:
>         (\x -> if x > 0 then 1.0 else 0.0) `fmap` n
> has also the type G Double but obviously does not have the normal
> distribution (since that random variable is discrete).
> There are other problems
>> Let's start with some limitation; we restrict ourselves to Gaussian
>> distributions and assume that the standard deviations are small
>> compared to the scales we deal with.
> That assumption is not stated in types and it is hard to see how can
> we enforce it. Nothing prevents us from writing
>         liftM2 n n
> in which case the variance will no longer be small compared with the
> mean.
> Just a technical remark: The way G a is written, it is a so-called
> restricted monad, which is not a monad (the adjective `restricted' is
> restrictive here).
>         http://okmij.org/ftp/Haskell/types.html#restricted-datatypes

The Hakubi Center for Advanced Research, Kyoto University

More information about the Haskell-Cafe mailing list