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 whereSource

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)].

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 
Interval Double 
Interval Int 
Interval Integer 
Interval () 
Interval IntM 
Interval a => Interval [a] 
(Interval a, Interval b) => Interval (a, b) 
(Interval a, Interval b, Interval c) => Interval (a, b, c) 
(Interval a, Interval b, Interval c, Interval d) => Interval (a, b, c, d) 
(Interval a, Interval b, Interval c, Interval d, Interval e) => Interval (a, b, c, d, e) 
(Interval a, Interval b, Interval c, Interval d, Interval e, Interval f) => Interval (a, b, c, d, e, f) 
(Interval a, Interval b, Interval c, Interval d, Interval e, Interval f, Interval g) => Interval (a, b, c, d, e, f, g) 

Zero class

class Zero a whereSource

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

Methods

zero :: a -> aSource

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 
Zero Double 
Zero Int 
Zero Integer 
Zero () 
Zero IntM 
Zero a => Zero [a] 
(Zero a, Zero b) => Zero (a, b) 
(Zero a, Zero b, Zero c) => Zero (a, b, c) 
(Zero a, Zero b, Zero c, Zero d) => Zero (a, b, c, d) 
(Zero a, Zero b, Zero c, Zero d, Zero e) => Zero (a, b, c, d, e) 
(Zero a, Zero b, Zero c, Zero d, Zero e, Zero f) => Zero (a, b, c, d, e, f) 
(Zero a, Zero b, Zero c, Zero d, Zero e, Zero f, Zero g) => Zero (a, b, c, d, e, f, g) 

Random class

We extend the class Random with tuples and lists.

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.