Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why sampleState much faster than runRVar? #38

Open
mvoidex opened this issue Feb 17, 2017 · 2 comments
Open

Why sampleState much faster than runRVar? #38

mvoidex opened this issue Feb 17, 2017 · 2 comments

Comments

@mvoidex
Copy link

mvoidex commented Feb 17, 2017

Why

sampleState (replicateM 1000000 stdNormal :: RVar [Double]) g

much faster (<1 src vs ~20 secs) than

runRVar (replicateM 1000000 stdNormal :: RVar [Double]) StdRandom

?

@idontgetoutmuch
Copy link
Member

Interesting. It would take some investigation. Maybe you could post a full program? I don't think sampling 1e6 normals should take even a second but maybe my intuition is incorrect.

@mvoidex
Copy link
Author

mvoidex commented Mar 25, 2017

Here

module Main where

import Control.Monad
import Control.DeepSeq
import Data.Random
import System.Random

main :: IO ()
main = do
	-- dbls <- (fst . sampleState (replicateM 1000000 stdNormal :: RVar [Double])) <$> newStdGen
	dbls <- runRVar (replicateM 1000000 stdNormal :: RVar [Double]) StdRandom
	dbls `deepseq` print (length dbls)

Results:
~1.5 secs vs ~20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants