[Haskell-cafe] Re: Re: Difference between div and /
Maciej Piechotka
uzytkownik2 at gmail.com
Thu Jun 3 07:02:44 EDT 2010
On Wed, 2010-06-02 at 16:11 +0200, Henning Thielemann wrote:
> Sorry, I missed this post.
>
>
> Maciej Piechotka schrieb:
>
> > Well - i tried to write some package dealing with distributions etc.
> >
> > If you have something like that:
> >
> > instance ... => Distribution (Linear a) a where
> > rand (Linear f s) g =
> > let (gf, gt) = genRange g
> > (v, g') = next g
> > in (g', f + (fromIntegral v * s) / fromIntegral (gt - gf))
> >
> > (I haven't check it but IMHO it is right implementation)
> >
> > Now I have following options:
> >
> > - Implement per Int/Int8/...
> > - Implement IntegerLinear and FractionalLinear separatly
>
> That is, what you need is a general division with rounding. But you
> might more generally want a custom type class with a method that selects
> an element from a set for given parameters gf, gt, v. This way, you
> could also handle distributions on Enumeration types. You certainly you
> do not want, say a division operation on Monday, Tuesday, ..., Sunday,
> but having a probability distribution of weekdays is very reasonable.
>
> Btw. you may want to have a look at:
> http://hackage.haskell.org/package/probability
Hmm. Thanks - however I fail to figure out how to do something like:
"generate a random number with normal distribution with average avg and
standard deviation stdev".
Regards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100603/32009648/attachment.bin
More information about the Haskell-Cafe
mailing list