random-fu-0.0.3.2: Random number generation

Data.Random.Distribution

Synopsis

# Documentation

class Distribution d t whereSource

A definition of a random variable's distribution. From the distribution an `RVar` can be created, or the distribution can be directly sampled using `sampleFrom` or `sample`.

Methods

rvar :: d t -> RVar tSource

Return a random variable with this distribution.

Instances

 Distribution StdUniform Bool Distribution StdUniform Char Distribution StdUniform Double Distribution StdUniform Float Distribution StdUniform Int Distribution StdUniform Int8 Distribution StdUniform Int16 Distribution StdUniform Int32 Distribution StdUniform Int64 Distribution StdUniform Ordering Distribution StdUniform Word8 Distribution StdUniform Word16 Distribution StdUniform Word32 Distribution StdUniform Word64 Distribution StdUniform () Distribution Uniform Bool Distribution Uniform Char Distribution Uniform Double Distribution Uniform Float Distribution Uniform Int Distribution Uniform Int8 Distribution Uniform Int16 Distribution Uniform Int32 Distribution Uniform Int64 Distribution Uniform Integer Distribution Uniform Ordering Distribution Uniform Word8 Distribution Uniform Word16 Distribution Uniform Word32 Distribution Uniform Word64 Distribution Uniform () (Floating a, Distribution StdUniform a) => Distribution Exponential a (RealFloat a, Distribution StdUniform a) => Distribution Rayleigh a (RealFloat a, Ord a, Distribution StdUniform a) => Distribution Triangular a (Num t, Ord t, Storable t) => Distribution Ziggurat t Distribution Normal Double Distribution Normal Float (Floating a, Ord a, Distribution Normal a, Distribution StdUniform a) => Distribution Gamma a (Fractional a, Distribution Gamma a, Distribution StdUniform a) => Distribution Beta a HasResolution r => Distribution StdUniform (Fixed r) HasResolution r => Distribution Uniform (Fixed r) (Fractional b, Ord b, Distribution StdUniform b) => Distribution (Bernoulli b) Bool Distribution (Bernoulli b[aqNA]) Bool => Distribution (Bernoulli b[aqNA]) Word64 Distribution (Bernoulli b[aqNA]) Bool => Distribution (Bernoulli b[aqNA]) Word32 Distribution (Bernoulli b[aqNA]) Bool => Distribution (Bernoulli b[aqNA]) Word16 Distribution (Bernoulli b[aqNA]) Bool => Distribution (Bernoulli b[aqNA]) Word8 Distribution (Bernoulli b[aqNA]) Bool => Distribution (Bernoulli b[aqNA]) Int64 Distribution (Bernoulli b[aqNA]) Bool => Distribution (Bernoulli b[aqNA]) Int32 Distribution (Bernoulli b[aqNA]) Bool => Distribution (Bernoulli b[aqNA]) Int16 Distribution (Bernoulli b[aqNA]) Bool => Distribution (Bernoulli b[aqNA]) Int8 Distribution (Bernoulli b[aqNA]) Bool => Distribution (Bernoulli b[aqNA]) Integer Distribution (Bernoulli b[aqNA]) Bool => Distribution (Bernoulli b[aqNA]) Int Distribution (Bernoulli b[ar4p]) Bool => Distribution (Bernoulli b[ar4p]) Double Distribution (Bernoulli b[ar4p]) Bool => Distribution (Bernoulli b[ar4p]) Float (Integral a, Floating b, Ord b, Distribution Normal b, Distribution StdUniform b) => Distribution (Erlang a) b (Floating b[aFcy], Ord b[aFcy], Distribution Beta b[aFcy], Distribution StdUniform b[aFcy]) => Distribution (Binomial b[aFcy]) Word64 (Floating b[aFcy], Ord b[aFcy], Distribution Beta b[aFcy], Distribution StdUniform b[aFcy]) => Distribution (Binomial b[aFcy]) Word32 (Floating b[aFcy], Ord b[aFcy], Distribution Beta b[aFcy], Distribution StdUniform b[aFcy]) => Distribution (Binomial b[aFcy]) Word16 (Floating b[aFcy], Ord b[aFcy], Distribution Beta b[aFcy], Distribution StdUniform b[aFcy]) => Distribution (Binomial b[aFcy]) Word8 (Floating b[aFcy], Ord b[aFcy], Distribution Beta b[aFcy], Distribution StdUniform b[aFcy]) => Distribution (Binomial b[aFcy]) Int64 (Floating b[aFcy], Ord b[aFcy], Distribution Beta b[aFcy], Distribution StdUniform b[aFcy]) => Distribution (Binomial b[aFcy]) Int32 (Floating b[aFcy], Ord b[aFcy], Distribution Beta b[aFcy], Distribution StdUniform b[aFcy]) => Distribution (Binomial b[aFcy]) Int16 (Floating b[aFcy], Ord b[aFcy], Distribution Beta b[aFcy], Distribution StdUniform b[aFcy]) => Distribution (Binomial b[aFcy]) Int8 (Floating b[aFcy], Ord b[aFcy], Distribution Beta b[aFcy], Distribution StdUniform b[aFcy]) => Distribution (Binomial b[aFcy]) Integer (Floating b[aFcy], Ord b[aFcy], Distribution Beta b[aFcy], Distribution StdUniform b[aFcy]) => Distribution (Binomial b[aFcy]) Int Distribution (Binomial b[aFwL]) Integer => Distribution (Binomial b[aFwL]) Double Distribution (Binomial b[aFwL]) Integer => Distribution (Binomial b[aFwL]) Float (RealFloat b[aHYt], Distribution StdUniform b[aHYt], Distribution (Erlang Word64) b[aHYt], Distribution (Binomial b[aHYt]) Word64) => Distribution (Poisson b[aHYt]) Word64 (RealFloat b[aHYt], Distribution StdUniform b[aHYt], Distribution (Erlang Word32) b[aHYt], Distribution (Binomial b[aHYt]) Word32) => Distribution (Poisson b[aHYt]) Word32 (RealFloat b[aHYt], Distribution StdUniform b[aHYt], Distribution (Erlang Word16) b[aHYt], Distribution (Binomial b[aHYt]) Word16) => Distribution (Poisson b[aHYt]) Word16 (RealFloat b[aHYt], Distribution StdUniform b[aHYt], Distribution (Erlang Word8) b[aHYt], Distribution (Binomial b[aHYt]) Word8) => Distribution (Poisson b[aHYt]) Word8 (RealFloat b[aHYt], Distribution StdUniform b[aHYt], Distribution (Erlang Int64) b[aHYt], Distribution (Binomial b[aHYt]) Int64) => Distribution (Poisson b[aHYt]) Int64 (RealFloat b[aHYt], Distribution StdUniform b[aHYt], Distribution (Erlang Int32) b[aHYt], Distribution (Binomial b[aHYt]) Int32) => Distribution (Poisson b[aHYt]) Int32 (RealFloat b[aHYt], Distribution StdUniform b[aHYt], Distribution (Erlang Int16) b[aHYt], Distribution (Binomial b[aHYt]) Int16) => Distribution (Poisson b[aHYt]) Int16 (RealFloat b[aHYt], Distribution StdUniform b[aHYt], Distribution (Erlang Int8) b[aHYt], Distribution (Binomial b[aHYt]) Int8) => Distribution (Poisson b[aHYt]) Int8 (RealFloat b[aHYt], Distribution StdUniform b[aHYt], Distribution (Erlang Integer) b[aHYt], Distribution (Binomial b[aHYt]) Integer) => Distribution (Poisson b[aHYt]) Integer (RealFloat b[aHYt], Distribution StdUniform b[aHYt], Distribution (Erlang Int) b[aHYt], Distribution (Binomial b[aHYt]) Int) => Distribution (Poisson b[aHYt]) Int Distribution (Poisson b[aIn0]) Integer => Distribution (Poisson b[aIn0]) Double Distribution (Poisson b[aIn0]) Integer => Distribution (Poisson b[aIn0]) Float (Num p, Ord p, Distribution Uniform p) => Distribution (Discrete p) a (Distribution (Bernoulli b) Bool, RealFloat a) => Distribution (Bernoulli b) (Complex a) (Distribution (Bernoulli b) Bool, Integral a) => Distribution (Bernoulli b) (Ratio a)

class Distribution d t => CDF d t whereSource

Methods

cdf :: d t -> t -> DoubleSource

Return the cumulative distribution function of this distribution. That is, a function taking `x :: t` to the probability that the next sample will return a value less than or equal to x, according to some order or partial order (not necessarily an obvious one).

In the case where `t` is an instance of Ord, `cdf` should correspond to the CDF with respect to that order.

In other cases, `cdf` is only required to satisfy the following law: `fmap (cdf d) (rvar d)` must be uniformly distributed over (0,1). Inclusion of either endpoint is optional, though the preferred range is (0,1].

Thus, `cdf` for a product type should not be a joint CDF as commonly defined, as that definition violates both conditions. Instead, it should be a univariate CDF over the product type. That is, it should represent the CDF with respect to the lexicographic order of the tuple.

Instances

 CDF StdUniform Bool CDF StdUniform Char CDF StdUniform Double CDF StdUniform Float CDF StdUniform Int CDF StdUniform Int8 CDF StdUniform Int16 CDF StdUniform Int32 CDF StdUniform Int64 CDF StdUniform Ordering CDF StdUniform Word8 CDF StdUniform Word16 CDF StdUniform Word32 CDF StdUniform Word64 CDF StdUniform () CDF Uniform Bool CDF Uniform Char CDF Uniform Double CDF Uniform Float CDF Uniform Int CDF Uniform Int8 CDF Uniform Int16 CDF Uniform Int32 CDF Uniform Int64 CDF Uniform Integer CDF Uniform Ordering CDF Uniform Word8 CDF Uniform Word16 CDF Uniform Word32 CDF Uniform Word64 CDF Uniform () (Real a, Distribution Exponential a) => CDF Exponential a (Real a, Distribution Rayleigh a) => CDF Rayleigh a (RealFrac a, Distribution Triangular a) => CDF Triangular a (Real a, Distribution Normal a) => CDF Normal a HasResolution r => CDF StdUniform (Fixed r) HasResolution r => CDF Uniform (Fixed r) (Distribution (Bernoulli b) Bool, Real b) => CDF (Bernoulli b) Bool CDF (Bernoulli b[aqNC]) Bool => CDF (Bernoulli b[aqNC]) Word64 CDF (Bernoulli b[aqNC]) Bool => CDF (Bernoulli b[aqNC]) Word32 CDF (Bernoulli b[aqNC]) Bool => CDF (Bernoulli b[aqNC]) Word16 CDF (Bernoulli b[aqNC]) Bool => CDF (Bernoulli b[aqNC]) Word8 CDF (Bernoulli b[aqNC]) Bool => CDF (Bernoulli b[aqNC]) Int64 CDF (Bernoulli b[aqNC]) Bool => CDF (Bernoulli b[aqNC]) Int32 CDF (Bernoulli b[aqNC]) Bool => CDF (Bernoulli b[aqNC]) Int16 CDF (Bernoulli b[aqNC]) Bool => CDF (Bernoulli b[aqNC]) Int8 CDF (Bernoulli b[aqNC]) Bool => CDF (Bernoulli b[aqNC]) Integer CDF (Bernoulli b[aqNC]) Bool => CDF (Bernoulli b[aqNC]) Int CDF (Bernoulli b[ar4r]) Bool => CDF (Bernoulli b[ar4r]) Double CDF (Bernoulli b[ar4r]) Bool => CDF (Bernoulli b[ar4r]) Float (Real b[aFcB], Distribution (Binomial b[aFcB]) Word64) => CDF (Binomial b[aFcB]) Word64 (Real b[aFcB], Distribution (Binomial b[aFcB]) Word32) => CDF (Binomial b[aFcB]) Word32 (Real b[aFcB], Distribution (Binomial b[aFcB]) Word16) => CDF (Binomial b[aFcB]) Word16 (Real b[aFcB], Distribution (Binomial b[aFcB]) Word8) => CDF (Binomial b[aFcB]) Word8 (Real b[aFcB], Distribution (Binomial b[aFcB]) Int64) => CDF (Binomial b[aFcB]) Int64 (Real b[aFcB], Distribution (Binomial b[aFcB]) Int32) => CDF (Binomial b[aFcB]) Int32 (Real b[aFcB], Distribution (Binomial b[aFcB]) Int16) => CDF (Binomial b[aFcB]) Int16 (Real b[aFcB], Distribution (Binomial b[aFcB]) Int8) => CDF (Binomial b[aFcB]) Int8 (Real b[aFcB], Distribution (Binomial b[aFcB]) Integer) => CDF (Binomial b[aFcB]) Integer (Real b[aFcB], Distribution (Binomial b[aFcB]) Int) => CDF (Binomial b[aFcB]) Int CDF (Binomial b[aFwO]) Integer => CDF (Binomial b[aFwO]) Double CDF (Binomial b[aFwO]) Integer => CDF (Binomial b[aFwO]) Float (Real b[aHYv], Distribution (Poisson b[aHYv]) Word64) => CDF (Poisson b[aHYv]) Word64 (Real b[aHYv], Distribution (Poisson b[aHYv]) Word32) => CDF (Poisson b[aHYv]) Word32 (Real b[aHYv], Distribution (Poisson b[aHYv]) Word16) => CDF (Poisson b[aHYv]) Word16 (Real b[aHYv], Distribution (Poisson b[aHYv]) Word8) => CDF (Poisson b[aHYv]) Word8 (Real b[aHYv], Distribution (Poisson b[aHYv]) Int64) => CDF (Poisson b[aHYv]) Int64 (Real b[aHYv], Distribution (Poisson b[aHYv]) Int32) => CDF (Poisson b[aHYv]) Int32 (Real b[aHYv], Distribution (Poisson b[aHYv]) Int16) => CDF (Poisson b[aHYv]) Int16 (Real b[aHYv], Distribution (Poisson b[aHYv]) Int8) => CDF (Poisson b[aHYv]) Int8 (Real b[aHYv], Distribution (Poisson b[aHYv]) Integer) => CDF (Poisson b[aHYv]) Integer (Real b[aHYv], Distribution (Poisson b[aHYv]) Int) => CDF (Poisson b[aHYv]) Int CDF (Poisson b[aIn2]) Integer => CDF (Poisson b[aIn2]) Double CDF (Poisson b[aIn2]) Integer => CDF (Poisson b[aIn2]) Float (CDF (Bernoulli b) Bool, RealFloat a) => CDF (Bernoulli b) (Complex a) (CDF (Bernoulli b) Bool, Integral a) => CDF (Bernoulli b) (Ratio a)

rvarT :: Distribution d t => d t -> RVarT n tSource

Return a random variable with the given distribution, pre-lifted to an arbitrary `RVarT`. Any arbitrary `RVar` can also be converted to an 'RVarT m' for an arbitrary `m`, using either `lift` or `sample`.