random-source: Generic basis for random number generators

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Warnings:

Random number generation based on entropy sources able to produce a small but well-defined set of primitive variates. Also includes facilities for "completing" partial implementations, making it easy to define new entropy sources in a way that is naturally forward-compatible. Now DEPRECATED: see README for further details.


[Skip to Readme]

Properties

Versions 0.3, 0.3.0.2, 0.3.0.4, 0.3.0.5, 0.3.0.6, 0.3.0.8, 0.3.0.10, 0.3.0.11, 0.3.0.12, 0.3.0.13, 0.3.0.13
Change log changelog.md
Dependencies base (>=3 && <4.16), flexible-defaults (>=0.0.0.2), mersenne-random-pure64, mtl (>=1 && <2 || >=2.0 && <2.3), mwc-random, primitive, random (>=1.2.0 && <1.3), stateref (>=0.3 && <0.4), syb, template-haskell, th-extras [details]
License LicenseRef-PublicDomain
Author James Cook <mokus@deepbondi.net>
Maintainer James Cook <mokus@deepbondi.net>
Category Math
Home page https://github.com/mokus0/random-fu
Source repo head: git clone https://github.com/mokus0/random-fu.git(random-source)
Uploaded by DominicSteinitz at 2023-09-14T09:28:44Z

Modules

Flags

Automatic Flags
NameDescriptionDefault
base4

base-4 and above do not include syb

Enabled
mtl2

mtl-2 has State, etc., as "type" rather than "newtype"

Enabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for random-source-0.3.0.13

[back to package description]

This is now deprecated and it is better to use the random package as the source of randomness.

Here's what you might have written before:

import qualified Data.Random as Random
import qualified Data.Random.Distribution.Bernoulli as Bernoulli

main :: IO ()
main = do
  x <- Random.sample $ Bernoulli.Bernoulli (0.5 :: Double) :: IO Double
  print x

And here's what you should write now (but there are many other options):

import qualified System.Random.Stateful as Random.Stateful
import qualified Data.Random as Random
import qualified Data.Random.Distribution.Bernoulli as Bernoulli
import qualified Control.Monad.Reader as Reader

main :: IO ()
main = do
  stdgen <- Random.Stateful.newIOGenM =<< Random.Stateful.newStdGen
  x <- Reader.runReaderT (Random.sample $ Bernoulli.Bernoulli (0.5 :: Double)) stdgen
        :: IO Double
  print x