Closed malie closed 9 years ago
Use floor
from Data.Array.Accelerate
.
You might find it useful to, instead of the explicit import and hiding lists that you have, use:
import Prelude as P
import Data.Array.Accelerate as A
And then when you try to use something defined in both (such asfloor
) ghc will tell you there are two available, and it will be obvious to pick A.floor
in this case.
That's great! Many thanks. With correct imports I also get the version working that generates random floats from 0.0 to 1.0.
Hi, I'm running into a problem when sampling from a vector of probabilities, to get a vector of booleans.
The program fails at runtime: Prelude.Ord.< applied to EDSL types: use (<*) instead
The code is at https://github.com/haskell-munich/accelerate-rbm/blob/master/Main.hs#L61
I built my own (very simple) PRNG that produces integers from 0 to 1023. The probabilities are from 0.0 to 1.0, so a <* should do the job (after scaling and flooring).
First I tried building a PRNG that produces random numbers between 0.0 and 1.0. That failed also at runtime. The fromIntegral, which I wanted to use to turn the Int64 into a Float, stopped. I'll reconstruct that if it's helpful tomorrow.
Do you have examples that use PRNGs to sample from probabilities?
Thanks, Markus