tag:blogger.com,1999:blog-5975524006824862804.post5727721235329443774..comments2014-07-03T03:57:09.689-07:00Comments on Paul's Pontifications: Anatomy of a new monadPaul Johnsonhttp://www.blogger.com/profile/07353083601285449293noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-5975524006824862804.post-88405417413040558142007-08-19T08:54:00.000-07:002007-08-19T08:54:00.000-07:00anonymous: I've had a look at the pages you refere...anonymous: I've had a look at the pages you referenced. But I'm not that much of a statistician.<BR/><BR/>It sounds like the MonteCarlo monad should be renamed the Markov monad. Am I right?<BR/><BR/>A non-uniform selection of next states could be done, but it would require a different monad. The type would be something like:<BR/><BR/>newtype Markov a = Markov (StdGen -> (StdGen, [(Int, a)])<BR/><BR/>The integer components in the returned values would be the relative probabilities of each value. The original monad is then the special case in which all these values are the same.<BR/><BR/>Would this do the job?Paul Johnsonhttp://www.blogger.com/profile/07353083601285449293noreply@blogger.comtag:blogger.com,1999:blog-5975524006824862804.post-56556419277866139012007-08-19T08:23:00.000-07:002007-08-19T08:23:00.000-07:00As your 2nd exercise for the reader indicates, a M...As your 2nd exercise for the reader indicates, a Monte Carlo monad would be interested in integrating by a large number of random samples. What you appear to have here is a Monad that would help with building uniformly distributed Markov chain simulations. Monte Carlo integration is often used in combination with a Markov chain to calculate the probabilities of the possible resulting states.<BR/><BR/>See:<BR/><BR/>http://en.wikipedia.org/wiki/Markov_chain<BR/>http://en.wikipedia.org/wiki/Markov_chain_Monte_Carlo<BR/><BR/>A possible improvement to the presented Monad would be to allow for non-uniformly distributed selection of the next state at each step.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5975524006824862804.post-75469732386873112722007-08-19T07:48:00.000-07:002007-08-19T07:48:00.000-07:00Could do. I was following in the footsteps of the...Could do. I was following in the footsteps of the QuickCheck "Gen" monad, which doesn't.<BR/><BR/>The best thing would probably be to do as you suggest, but then have an "evalMonteCarlo" which throws away the state.<BR/><BR/>I did wonder about genericising the whole thing by RandomGen, but decided not to bother.Paul Johnsonhttp://www.blogger.com/profile/07353083601285449293noreply@blogger.comtag:blogger.com,1999:blog-5975524006824862804.post-7105399270648793342007-08-19T06:24:00.000-07:002007-08-19T06:24:00.000-07:00Shouldn't your runMonteCarlo function return the g...Shouldn't your runMonteCarlo function return the generator along with the result, so that it can be threaded with other random functions? I.e.:<BR/><BR/>runMonteCarlo :: MonteCarlo a -> StdGen -> (StdGen, Maybe a)<BR/><BR/><BR/>Or perhaps:<BR/><BR/>runMonteCarlo :: RandomGen g => MonteCarlo a -> g -> (g, Maybe a)Neil Bartletthttp://www.blogger.com/profile/08588098030811273044noreply@blogger.com