The Quipper System

Safe HaskellNone

Libraries.Sampling

Contents

Description

This module provides functions for generating lists of samples from a range of input values. This is primarily useful for generating test cases. Ranges can be specified for types that are members of the Interval class. Each sampling procedure generates a (finite or infinite) list of values from the range. We provide sampling procedures for

Synopsis

Interval class

class Interval a where Source #

The Interval class contains types for which an interval of values can be specified by giving a lower bound and an upper bound. Intervals are specified as interval min max, for example:

interval (0,0) (1,2) = [(0,0),(0,1),(0,2),(1,0),(1,1),(1,2)].

Minimal complete definition

interval

Methods

interval :: a -> a -> [a] Source #

Takes a range (min,max) and returns a list of all values with lower bound min and upper bound max.

Instances

Interval Bool # 

Methods

interval :: Bool -> Bool -> [Bool] Source #

Interval Double # 

Methods

interval :: Double -> Double -> [Double] Source #

Interval Int # 

Methods

interval :: Int -> Int -> [Int] Source #

Interval Integer # 
Interval () # 

Methods

interval :: () -> () -> [()] Source #

Interval IntM # 

Methods

interval :: IntM -> IntM -> [IntM] Source #

Interval a => Interval [a] # 

Methods

interval :: [a] -> [a] -> [[a]] Source #

(Interval a, Interval b) => Interval (a, b) # 

Methods

interval :: (a, b) -> (a, b) -> [(a, b)] Source #

(Interval a, Interval b, Interval c) => Interval (a, b, c) # 

Methods

interval :: (a, b, c) -> (a, b, c) -> [(a, b, c)] Source #

(Interval a, Interval b, Interval c, Interval d) => Interval (a, b, c, d) # 

Methods

interval :: (a, b, c, d) -> (a, b, c, d) -> [(a, b, c, d)] Source #

(Interval a, Interval b, Interval c, Interval d, Interval e) => Interval (a, b, c, d, e) # 

Methods

interval :: (a, b, c, d, e) -> (a, b, c, d, e) -> [(a, b, c, d, e)] Source #

(Interval a, Interval b, Interval c, Interval d, Interval e, Interval f) => Interval (a, b, c, d, e, f) # 

Methods

interval :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> [(a, b, c, d, e, f)] Source #

(Interval a, Interval b, Interval c, Interval d, Interval e, Interval f, Interval g) => Interval (a, b, c, d, e, f, g) # 

Methods

interval :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> [(a, b, c, d, e, f, g)] Source #

Zero class

class Zero a where Source #

Types in the Zero class have an "origin", i.e., an element that can conveniently serve as the starting point for intervals.

Minimal complete definition

zero

Methods

zero :: a -> a Source #

Inputs any element of the type and outputs the corresponding "zero" element, for example:

zero ([1,2],3,True) = ([0,0],0,False)

Instances

Zero Bool # 

Methods

zero :: Bool -> Bool Source #

Zero Double # 

Methods

zero :: Double -> Double Source #

Zero Int # 

Methods

zero :: Int -> Int Source #

Zero Integer # 

Methods

zero :: Integer -> Integer Source #

Zero () # 

Methods

zero :: () -> () Source #

Zero IntM # 

Methods

zero :: IntM -> IntM Source #

Zero a => Zero [a] # 

Methods

zero :: [a] -> [a] Source #

(Zero a, Zero b) => Zero (a, b) # 

Methods

zero :: (a, b) -> (a, b) Source #

(Zero a, Zero b, Zero c) => Zero (a, b, c) # 

Methods

zero :: (a, b, c) -> (a, b, c) Source #

(Zero a, Zero b, Zero c, Zero d) => Zero (a, b, c, d) # 

Methods

zero :: (a, b, c, d) -> (a, b, c, d) Source #

(Zero a, Zero b, Zero c, Zero d, Zero e) => Zero (a, b, c, d, e) # 

Methods

zero :: (a, b, c, d, e) -> (a, b, c, d, e) Source #

(Zero a, Zero b, Zero c, Zero d, Zero e, Zero f) => Zero (a, b, c, d, e, f) # 

Methods

zero :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) Source #

(Zero a, Zero b, Zero c, Zero d, Zero e, Zero f, Zero g) => Zero (a, b, c, d, e, f, g) # 

Methods

zero :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source #

Random class

We extend the class Random with tuples and lists.

class Random a #

With a source of random number supply in hand, the Random class allows the programmer to extract random values of a variety of types.

Minimal complete definition: randomR and random.

Minimal complete definition

randomR, random

Instances

Random Bool 

Methods

randomR :: RandomGen g => (Bool, Bool) -> g -> (Bool, g) #

random :: RandomGen g => g -> (Bool, g) #

randomRs :: RandomGen g => (Bool, Bool) -> g -> [Bool] #

randoms :: RandomGen g => g -> [Bool] #

randomRIO :: (Bool, Bool) -> IO Bool #

randomIO :: IO Bool #

Random Char 

Methods

randomR :: RandomGen g => (Char, Char) -> g -> (Char, g) #

random :: RandomGen g => g -> (Char, g) #

randomRs :: RandomGen g => (Char, Char) -> g -> [Char] #

randoms :: RandomGen g => g -> [Char] #

randomRIO :: (Char, Char) -> IO Char #

randomIO :: IO Char #

Random Double 

Methods

randomR :: RandomGen g => (Double, Double) -> g -> (Double, g) #

random :: RandomGen g => g -> (Double, g) #

randomRs :: RandomGen g => (Double, Double) -> g -> [Double] #

randoms :: RandomGen g => g -> [Double] #

randomRIO :: (Double, Double) -> IO Double #

randomIO :: IO Double #

Random Float 

Methods

randomR :: RandomGen g => (Float, Float) -> g -> (Float, g) #

random :: RandomGen g => g -> (Float, g) #

randomRs :: RandomGen g => (Float, Float) -> g -> [Float] #

randoms :: RandomGen g => g -> [Float] #

randomRIO :: (Float, Float) -> IO Float #

randomIO :: IO Float #

Random Int 

Methods

randomR :: RandomGen g => (Int, Int) -> g -> (Int, g) #

random :: RandomGen g => g -> (Int, g) #

randomRs :: RandomGen g => (Int, Int) -> g -> [Int] #

randoms :: RandomGen g => g -> [Int] #

randomRIO :: (Int, Int) -> IO Int #

randomIO :: IO Int #

Random Int8 

Methods

randomR :: RandomGen g => (Int8, Int8) -> g -> (Int8, g) #

random :: RandomGen g => g -> (Int8, g) #

randomRs :: RandomGen g => (Int8, Int8) -> g -> [Int8] #

randoms :: RandomGen g => g -> [Int8] #

randomRIO :: (Int8, Int8) -> IO Int8 #

randomIO :: IO Int8 #

Random Int16 

Methods

randomR :: RandomGen g => (Int16, Int16) -> g -> (Int16, g) #

random :: RandomGen g => g -> (Int16, g) #

randomRs :: RandomGen g => (Int16, Int16) -> g -> [Int16] #

randoms :: RandomGen g => g -> [Int16] #

randomRIO :: (Int16, Int16) -> IO Int16 #

randomIO :: IO Int16 #

Random Int32 

Methods

randomR :: RandomGen g => (Int32, Int32) -> g -> (Int32, g) #

random :: RandomGen g => g -> (Int32, g) #

randomRs :: RandomGen g => (Int32, Int32) -> g -> [Int32] #

randoms :: RandomGen g => g -> [Int32] #

randomRIO :: (Int32, Int32) -> IO Int32 #

randomIO :: IO Int32 #

Random Int64 

Methods

randomR :: RandomGen g => (Int64, Int64) -> g -> (Int64, g) #

random :: RandomGen g => g -> (Int64, g) #

randomRs :: RandomGen g => (Int64, Int64) -> g -> [Int64] #

randoms :: RandomGen g => g -> [Int64] #

randomRIO :: (Int64, Int64) -> IO Int64 #

randomIO :: IO Int64 #

Random Integer 

Methods

randomR :: RandomGen g => (Integer, Integer) -> g -> (Integer, g) #

random :: RandomGen g => g -> (Integer, g) #

randomRs :: RandomGen g => (Integer, Integer) -> g -> [Integer] #

randoms :: RandomGen g => g -> [Integer] #

randomRIO :: (Integer, Integer) -> IO Integer #

randomIO :: IO Integer #

Random Word 

Methods

randomR :: RandomGen g => (Word, Word) -> g -> (Word, g) #

random :: RandomGen g => g -> (Word, g) #

randomRs :: RandomGen g => (Word, Word) -> g -> [Word] #

randoms :: RandomGen g => g -> [Word] #

randomRIO :: (Word, Word) -> IO Word #

randomIO :: IO Word #

Random Word8 

Methods

randomR :: RandomGen g => (Word8, Word8) -> g -> (Word8, g) #

random :: RandomGen g => g -> (Word8, g) #

randomRs :: RandomGen g => (Word8, Word8) -> g -> [Word8] #

randoms :: RandomGen g => g -> [Word8] #

randomRIO :: (Word8, Word8) -> IO Word8 #

randomIO :: IO Word8 #

Random Word16 

Methods

randomR :: RandomGen g => (Word16, Word16) -> g -> (Word16, g) #

random :: RandomGen g => g -> (Word16, g) #

randomRs :: RandomGen g => (Word16, Word16) -> g -> [Word16] #

randoms :: RandomGen g => g -> [Word16] #

randomRIO :: (Word16, Word16) -> IO Word16 #

randomIO :: IO Word16 #

Random Word32 

Methods

randomR :: RandomGen g => (Word32, Word32) -> g -> (Word32, g) #

random :: RandomGen g => g -> (Word32, g) #

randomRs :: RandomGen g => (Word32, Word32) -> g -> [Word32] #

randoms :: RandomGen g => g -> [Word32] #

randomRIO :: (Word32, Word32) -> IO Word32 #

randomIO :: IO Word32 #

Random Word64 

Methods

randomR :: RandomGen g => (Word64, Word64) -> g -> (Word64, g) #

random :: RandomGen g => g -> (Word64, g) #

randomRs :: RandomGen g => (Word64, Word64) -> g -> [Word64] #

randoms :: RandomGen g => g -> [Word64] #

randomRIO :: (Word64, Word64) -> IO Word64 #

randomIO :: IO Word64 #

Random CChar 

Methods

randomR :: RandomGen g => (CChar, CChar) -> g -> (CChar, g) #

random :: RandomGen g => g -> (CChar, g) #

randomRs :: RandomGen g => (CChar, CChar) -> g -> [CChar] #

randoms :: RandomGen g => g -> [CChar] #

randomRIO :: (CChar, CChar) -> IO CChar #

randomIO :: IO CChar #

Random CSChar 

Methods

randomR :: RandomGen g => (CSChar, CSChar) -> g -> (CSChar, g) #

random :: RandomGen g => g -> (CSChar, g) #

randomRs :: RandomGen g => (CSChar, CSChar) -> g -> [CSChar] #

randoms :: RandomGen g => g -> [CSChar] #

randomRIO :: (CSChar, CSChar) -> IO CSChar #

randomIO :: IO CSChar #

Random CUChar 

Methods

randomR :: RandomGen g => (CUChar, CUChar) -> g -> (CUChar, g) #

random :: RandomGen g => g -> (CUChar, g) #

randomRs :: RandomGen g => (CUChar, CUChar) -> g -> [CUChar] #

randoms :: RandomGen g => g -> [CUChar] #

randomRIO :: (CUChar, CUChar) -> IO CUChar #

randomIO :: IO CUChar #

Random CShort 

Methods

randomR :: RandomGen g => (CShort, CShort) -> g -> (CShort, g) #

random :: RandomGen g => g -> (CShort, g) #

randomRs :: RandomGen g => (CShort, CShort) -> g -> [CShort] #

randoms :: RandomGen g => g -> [CShort] #

randomRIO :: (CShort, CShort) -> IO CShort #

randomIO :: IO CShort #

Random CUShort 

Methods

randomR :: RandomGen g => (CUShort, CUShort) -> g -> (CUShort, g) #

random :: RandomGen g => g -> (CUShort, g) #

randomRs :: RandomGen g => (CUShort, CUShort) -> g -> [CUShort] #

randoms :: RandomGen g => g -> [CUShort] #

randomRIO :: (CUShort, CUShort) -> IO CUShort #

randomIO :: IO CUShort #

Random CInt 

Methods

randomR :: RandomGen g => (CInt, CInt) -> g -> (CInt, g) #

random :: RandomGen g => g -> (CInt, g) #

randomRs :: RandomGen g => (CInt, CInt) -> g -> [CInt] #

randoms :: RandomGen g => g -> [CInt] #

randomRIO :: (CInt, CInt) -> IO CInt #

randomIO :: IO CInt #

Random CUInt 

Methods

randomR :: RandomGen g => (CUInt, CUInt) -> g -> (CUInt, g) #

random :: RandomGen g => g -> (CUInt, g) #

randomRs :: RandomGen g => (CUInt, CUInt) -> g -> [CUInt] #

randoms :: RandomGen g => g -> [CUInt] #

randomRIO :: (CUInt, CUInt) -> IO CUInt #

randomIO :: IO CUInt #

Random CLong 

Methods

randomR :: RandomGen g => (CLong, CLong) -> g -> (CLong, g) #

random :: RandomGen g => g -> (CLong, g) #

randomRs :: RandomGen g => (CLong, CLong) -> g -> [CLong] #

randoms :: RandomGen g => g -> [CLong] #

randomRIO :: (CLong, CLong) -> IO CLong #

randomIO :: IO CLong #

Random CULong 

Methods

randomR :: RandomGen g => (CULong, CULong) -> g -> (CULong, g) #

random :: RandomGen g => g -> (CULong, g) #

randomRs :: RandomGen g => (CULong, CULong) -> g -> [CULong] #

randoms :: RandomGen g => g -> [CULong] #

randomRIO :: (CULong, CULong) -> IO CULong #

randomIO :: IO CULong #

Random CLLong 

Methods

randomR :: RandomGen g => (CLLong, CLLong) -> g -> (CLLong, g) #

random :: RandomGen g => g -> (CLLong, g) #

randomRs :: RandomGen g => (CLLong, CLLong) -> g -> [CLLong] #

randoms :: RandomGen g => g -> [CLLong] #

randomRIO :: (CLLong, CLLong) -> IO CLLong #

randomIO :: IO CLLong #

Random CULLong 

Methods

randomR :: RandomGen g => (CULLong, CULLong) -> g -> (CULLong, g) #

random :: RandomGen g => g -> (CULLong, g) #

randomRs :: RandomGen g => (CULLong, CULLong) -> g -> [CULLong] #

randoms :: RandomGen g => g -> [CULLong] #

randomRIO :: (CULLong, CULLong) -> IO CULLong #

randomIO :: IO CULLong #

Random CFloat 

Methods

randomR :: RandomGen g => (CFloat, CFloat) -> g -> (CFloat, g) #

random :: RandomGen g => g -> (CFloat, g) #

randomRs :: RandomGen g => (CFloat, CFloat) -> g -> [CFloat] #

randoms :: RandomGen g => g -> [CFloat] #

randomRIO :: (CFloat, CFloat) -> IO CFloat #

randomIO :: IO CFloat #

Random CDouble 

Methods

randomR :: RandomGen g => (CDouble, CDouble) -> g -> (CDouble, g) #

random :: RandomGen g => g -> (CDouble, g) #

randomRs :: RandomGen g => (CDouble, CDouble) -> g -> [CDouble] #

randoms :: RandomGen g => g -> [CDouble] #

randomRIO :: (CDouble, CDouble) -> IO CDouble #

randomIO :: IO CDouble #

Random CPtrdiff 
Random CSize 

Methods

randomR :: RandomGen g => (CSize, CSize) -> g -> (CSize, g) #

random :: RandomGen g => g -> (CSize, g) #

randomRs :: RandomGen g => (CSize, CSize) -> g -> [CSize] #

randoms :: RandomGen g => g -> [CSize] #

randomRIO :: (CSize, CSize) -> IO CSize #

randomIO :: IO CSize #

Random CWchar 

Methods

randomR :: RandomGen g => (CWchar, CWchar) -> g -> (CWchar, g) #

random :: RandomGen g => g -> (CWchar, g) #

randomRs :: RandomGen g => (CWchar, CWchar) -> g -> [CWchar] #

randoms :: RandomGen g => g -> [CWchar] #

randomRIO :: (CWchar, CWchar) -> IO CWchar #

randomIO :: IO CWchar #

Random CSigAtomic 
Random CIntPtr 

Methods

randomR :: RandomGen g => (CIntPtr, CIntPtr) -> g -> (CIntPtr, g) #

random :: RandomGen g => g -> (CIntPtr, g) #

randomRs :: RandomGen g => (CIntPtr, CIntPtr) -> g -> [CIntPtr] #

randoms :: RandomGen g => g -> [CIntPtr] #

randomRIO :: (CIntPtr, CIntPtr) -> IO CIntPtr #

randomIO :: IO CIntPtr #

Random CUIntPtr 
Random CIntMax 

Methods

randomR :: RandomGen g => (CIntMax, CIntMax) -> g -> (CIntMax, g) #

random :: RandomGen g => g -> (CIntMax, g) #

randomRs :: RandomGen g => (CIntMax, CIntMax) -> g -> [CIntMax] #

randoms :: RandomGen g => g -> [CIntMax] #

randomRIO :: (CIntMax, CIntMax) -> IO CIntMax #

randomIO :: IO CIntMax #

Random CUIntMax 
Precision e => Random (FixedPrec e) 

Methods

randomR :: RandomGen g => (FixedPrec e, FixedPrec e) -> g -> (FixedPrec e, g) #

random :: RandomGen g => g -> (FixedPrec e, g) #

randomRs :: RandomGen g => (FixedPrec e, FixedPrec e) -> g -> [FixedPrec e] #

randoms :: RandomGen g => g -> [FixedPrec e] #

randomRIO :: (FixedPrec e, FixedPrec e) -> IO (FixedPrec e) #

randomIO :: IO (FixedPrec e) #

Functions

sample_all :: Interval a => a -> a -> [a] Source #

sample_all min max: returns a list of all elements from the range (min,max). This is actually just a synonym of interval.

sample_step :: (Integral a, Integral b, Interval c) => a -> b -> c -> c -> [c] Source #

sample_step n k min max: returns every nth element from the range (min,max), starting with the kth element.

sample_random :: (Random a, RandomGen g) => g -> a -> a -> [a] Source #

sample_random g min max: returns an infinite list of random samples from the range (min,max), using the random number generator g.

sample_all0 :: (Zero a, Interval a) => a -> [a] Source #

A variant of sample_all that omits the min argument, and uses the zero element of the type instead.

sample_step0 :: (Integral a, Integral b, Zero c, Interval c) => a -> b -> c -> [c] Source #

A variant of sample_step that omits the min argument, and uses the zero element of the type instead.

sample_random0 :: (Random a, Zero a, RandomGen g) => g -> a -> [a] Source #

A variant of sample_random that omits the min argument, and uses the zero element of the type instead.

Orphan instances

Random () #

0-tuples

Methods

randomR :: RandomGen g => ((), ()) -> g -> ((), g) #

random :: RandomGen g => g -> ((), g) #

randomRs :: RandomGen g => ((), ()) -> g -> [()] #

randoms :: RandomGen g => g -> [()] #

randomRIO :: ((), ()) -> IO () #

randomIO :: IO () #

Random a => Random [a] #

Lists

Methods

randomR :: RandomGen g => ([a], [a]) -> g -> ([a], g) #

random :: RandomGen g => g -> ([a], g) #

randomRs :: RandomGen g => ([a], [a]) -> g -> [[a]] #

randoms :: RandomGen g => g -> [[a]] #

randomRIO :: ([a], [a]) -> IO [a] #

randomIO :: IO [a] #

(Random a, Random b) => Random (a, b) #

Pairs

Methods

randomR :: RandomGen g => ((a, b), (a, b)) -> g -> ((a, b), g) #

random :: RandomGen g => g -> ((a, b), g) #

randomRs :: RandomGen g => ((a, b), (a, b)) -> g -> [(a, b)] #

randoms :: RandomGen g => g -> [(a, b)] #

randomRIO :: ((a, b), (a, b)) -> IO (a, b) #

randomIO :: IO (a, b) #

(Random a, Random b, Random c) => Random (a, b, c) #

Triples

Methods

randomR :: RandomGen g => ((a, b, c), (a, b, c)) -> g -> ((a, b, c), g) #

random :: RandomGen g => g -> ((a, b, c), g) #

randomRs :: RandomGen g => ((a, b, c), (a, b, c)) -> g -> [(a, b, c)] #

randoms :: RandomGen g => g -> [(a, b, c)] #

randomRIO :: ((a, b, c), (a, b, c)) -> IO (a, b, c) #

randomIO :: IO (a, b, c) #

(Random a, Random b, Random c, Random d) => Random (a, b, c, d) #

4-Tuples

Methods

randomR :: RandomGen g => ((a, b, c, d), (a, b, c, d)) -> g -> ((a, b, c, d), g) #

random :: RandomGen g => g -> ((a, b, c, d), g) #

randomRs :: RandomGen g => ((a, b, c, d), (a, b, c, d)) -> g -> [(a, b, c, d)] #

randoms :: RandomGen g => g -> [(a, b, c, d)] #

randomRIO :: ((a, b, c, d), (a, b, c, d)) -> IO (a, b, c, d) #

randomIO :: IO (a, b, c, d) #

(Random a, Random b, Random c, Random d, Random e) => Random (a, b, c, d, e) #

5-Tuples

Methods

randomR :: RandomGen g => ((a, b, c, d, e), (a, b, c, d, e)) -> g -> ((a, b, c, d, e), g) #

random :: RandomGen g => g -> ((a, b, c, d, e), g) #

randomRs :: RandomGen g => ((a, b, c, d, e), (a, b, c, d, e)) -> g -> [(a, b, c, d, e)] #

randoms :: RandomGen g => g -> [(a, b, c, d, e)] #

randomRIO :: ((a, b, c, d, e), (a, b, c, d, e)) -> IO (a, b, c, d, e) #

randomIO :: IO (a, b, c, d, e) #

(Random a, Random b, Random c, Random d, Random e, Random f) => Random (a, b, c, d, e, f) #

6-Tuples

Methods

randomR :: RandomGen g => ((a, b, c, d, e, f), (a, b, c, d, e, f)) -> g -> ((a, b, c, d, e, f), g) #

random :: RandomGen g => g -> ((a, b, c, d, e, f), g) #

randomRs :: RandomGen g => ((a, b, c, d, e, f), (a, b, c, d, e, f)) -> g -> [(a, b, c, d, e, f)] #

randoms :: RandomGen g => g -> [(a, b, c, d, e, f)] #

randomRIO :: ((a, b, c, d, e, f), (a, b, c, d, e, f)) -> IO (a, b, c, d, e, f) #

randomIO :: IO (a, b, c, d, e, f) #

(Random a, Random b, Random c, Random d, Random e, Random f, Random g) => Random (a, b, c, d, e, f, g) #

7-Tuples

Methods

randomR :: RandomGen g => ((a, b, c, d, e, f, g), (a, b, c, d, e, f, g)) -> g -> ((a, b, c, d, e, f, g), g) #

random :: RandomGen g => g -> ((a, b, c, d, e, f, g), g) #

randomRs :: RandomGen g => ((a, b, c, d, e, f, g), (a, b, c, d, e, f, g)) -> g -> [(a, b, c, d, e, f, g)] #

randoms :: RandomGen g => g -> [(a, b, c, d, e, f, g)] #

randomRIO :: ((a, b, c, d, e, f, g), (a, b, c, d, e, f, g)) -> IO (a, b, c, d, e, f, g) #

randomIO :: IO (a, b, c, d, e, f, g) #