I have written this code in Haskell which gives an unresolved overloading error.
The function bernoulli should give the probability of j successes occuring in n
trials, if each trial has a probability of p.
fac 0 = 1
fac n = n * fac(n - 1)
binom n j = (fac n)/((fac j)*(fac (n - j)))
Actually, I don't know what type you want p to be, so you might not
need the fromIntegral.
On Mar 31, 2007, at 10:21 , Lennart Augustsson wrote:
The definition of fac forces the result to have the same type as
the argument.
Then in binom you use / which forces the type to be Fractional.
It's working now, thank you.
I changed the definition to
binom n j = div (fac n) ((fac j)*(fac (n - j)))
bernoulli n p j = fromIntegral(binom n j)*(p ^ j) * ((1 - p)^(n - j))
Lennart Augustsson [EMAIL PROTECTED] wrote: The definition of fac forces the
result to have the same type as the
On 3/31/07, Scott Brown [EMAIL PROTECTED] wrote:
It's working now, thank you.
I changed the definition to
binom n j = div (fac n) ((fac j)*(fac (n - j)))
bernoulli n p j = fromIntegral(binom n j)*(p ^ j) * ((1 - p)^(n - j))
As a matter of style suggestion, it might make 'binom' more clear
Bryan Burgers wrote:
On 3/31/07, Scott Brown [EMAIL PROTECTED] wrote:
It's working now, thank you.
I changed the definition to
binom n j = div (fac n) ((fac j)*(fac (n - j)))
bernoulli n p j = fromIntegral(binom n j)*(p ^ j) * ((1 - p)^(n - j))
As a matter of style suggestion, it might
On Friday 30 March 2007 06:59, Stefan O'Rear wrote:
Anyway, I think parsec is *far* too big a hammer for the nail you're trying
to hit.
In the end , the big hammer solution has become
parseLine = fmap (map fst. filter snd) $ many parser
where parser = do w - option (,False) parseAWord
Hi,
Has anyone got the GHC module HGL to work on Mac OS X? If so I'd be
very interested to know how.
Cheers,
Ruben
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe