The boltzmann-samplers package

[Tags:library, mit]

Random generators with a uniform distribution conditioned to a given size. See also testing-feat, which is currently a faster method with similar results.

[Skip to Readme]


Dependencies ad, base (>=4.8 && <5), containers, hashable, hmatrix, ieee754, MonadRandom, mtl, QuickCheck, transformers, unordered-containers, vector [details]
License MIT
Author Li-yao Xia
Category Data, Generic, Random
Home page
Source repository head: git clone
Uploaded Sun Mar 5 20:25:38 UTC 2017 by lyxia
Updated Sun Mar 5 22:43:09 UTC 2017 by lyxia to revision 1
Distributions LTSHaskell:, NixOS:, Stackage:, Tumbleweed:
Downloads 51 total (14 in the last 30 days)
0 []
Status Docs available [build log]
Last success reported on 2017-03-05 [all 1 reports]
Hackage Matrix CI




testEnable testing. Disabled by default because the current test suite is slow and can fail with non-zero probability.DisabledManual

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


Maintainer's Corner

For package maintainers and hackage trustees

Readme for boltzmann-samplers

Readme for boltzmann-samplers-

Boltzmann samplers Hackage Build Status


Define sized random generators for Data.Data generic types.

    {-# LANGUAGE DeriveDataTypeable #-}

    import Data.Data
    import Test.QuickCheck
    import Boltzmann.Data

    data Term = Lambda Int Term | App Term Term | Var Int
      deriving (Show, Data)

    instance Arbitrary Term where
      arbitrary = sized $ generatorPWith [positiveInts]

    positiveInts :: Alias Gen
    positiveInts =
      alias $ \() -> fmap getPositive arbitrary :: Gen Int

    main = sample (arbitrary :: Gen Term)
  • Objects of the same size (number of constructors) occur with the same probability (see Duchon et al., references below).
  • Implements rejection sampling and pointing.
  • Works with QuickCheck and MonadRandom, but also similar user-defined monads for randomness (just implement MonadRandomLike).
  • Can be tweaked somewhat with user defined generators.


An experimental interface to obtain Boltzmann samplers from an applicative specification of a combinatorial system.

No documentation (yet).