Thanks for the reply.

On 2/25/07, Marc Weber <[EMAIL PROTECTED]> wrote:
> time-consuming and it takes months in R. I like the language very much
> so far, but I do miss some important functions in R which can generate
                                                    ^ typo ? ;)
> But for rnorm, if I use "foreign import ccall rnorm :: Double -> Double
> -> IO Double", then my main function should carry IO monad all the time.
> Maybe the better way is that I should "encapsulate" it into a state
> monad rng -> (rng, randomnumber). Therefore for rnorm, I should first
> write a wrapper in c like
> seed2 rnorm_wrapper(seed1, parameters){
>       set_seed(seed1);
>       rnorm(parameters);
>       get_seed(seed2);
> }
set_seed
rnorm
get_seed
doesn't have any side effect as long as you consider this sequence beeing

rnorm itself has side effect, right? It changes the seed for global
random generator.
That is why I think I need rnorm_wrapper to "purify" it.

atomic. If you don't use multithreading it should work fine.  If you want to
use multithreading have a look at
http://haskell.org/haskellwiki/GHC/Concurrency, especially at
"Software Transactional Memory (STM)" which is what you might need here (?)
> and then write another wrapper for rnorm_wrapper in haskell.
>
> Can somebody tell me if this is the right approach? Thank you!

Have a look at (haskell.org -> library and tools -> Mathematics
(http://haskell.org/haskellwiki/Libraries_and_tools/Mathematics)
library "Probabilistic Functional Programming"
Perhaps this lib does exactly what you need.

I did see this, but I think it is not enough for me.


There is another important source of packages:
http://hackage.haskell.org/packages/archive/pkg-list.html

Which way to go? I'm not a haskell expert so I can't tell you.
It depends on what you need and how much time you want to spent on this topic ;)

hope this helps
Marc Weber
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to