Copyright | (c) Sam Stites 2017 |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Torch.Indef.Dynamic.Tensor.Random.TH
Description
Torch provides accurate mathematical random generation, based on Mersenne Twister random number generator.
FIXME: verify these are all correct -- I am working off of <https://github.com/torch/torch7/blob/aed31711c6b8846b8337a263a7f9f998697994e7/doc/random.md random.md> from torch/torch7.
Synopsis
- _random :: Dynamic -> Generator -> IO ()
- random :: Dims (d :: [Nat]) -> Generator -> IO Dynamic
- _clampedRandom :: Integral a => Dynamic -> Generator -> Ord2Tuple a -> IO ()
- clampedRandom :: Dims (d :: [Nat]) -> Generator -> Ord2Tuple Integer -> IO Dynamic
- _cappedRandom :: Integral a => Dynamic -> Generator -> a -> IO ()
- cappedRandom :: Dims (d :: [Nat]) -> Generator -> Word64 -> IO Dynamic
- _geometric :: Dynamic -> Generator -> HsAccReal -> IO ()
- geometric :: Dims (d :: [Nat]) -> Generator -> OpenUnit HsAccReal -> IO Dynamic
- _bernoulli :: Dynamic -> Generator -> HsAccReal -> IO ()
- bernoulli :: Dims (d :: [Nat]) -> Generator -> ClosedUnit HsAccReal -> IO Dynamic
- _bernoulli_FloatTensor :: Dynamic -> Generator -> FloatDynamic -> IO ()
- bernoulli_FloatTensor :: Dims (d :: [Nat]) -> Generator -> FloatDynamic -> IO Dynamic
- _bernoulli_DoubleTensor :: Dynamic -> Generator -> DoubleDynamic -> IO ()
- bernoulli_DoubleTensor :: Dims (d :: [Nat]) -> Generator -> DoubleDynamic -> IO Dynamic
- _uniform :: Dynamic -> Generator -> Ord2Tuple HsAccReal -> IO ()
- uniform :: Dims (d :: [Nat]) -> Generator -> Ord2Tuple HsAccReal -> IO Dynamic
- _normal :: Dynamic -> Generator -> HsAccReal -> Positive HsAccReal -> IO ()
- normal :: Dims (d :: [Nat]) -> Generator -> HsAccReal -> Positive HsAccReal -> IO Dynamic
- _normal_means :: Dynamic -> Generator -> Dynamic -> Positive HsAccReal -> IO ()
- normal_means :: Dims (d :: [Nat]) -> Generator -> Dynamic -> Positive HsAccReal -> IO Dynamic
- _normal_stddevs :: Dynamic -> Generator -> HsAccReal -> Dynamic -> IO ()
- normal_stddevs :: Dims (d :: [Nat]) -> Generator -> HsAccReal -> Dynamic -> IO Dynamic
- _normal_means_stddevs :: Dynamic -> Generator -> Dynamic -> Dynamic -> IO ()
- normal_means_stddevs :: Dims (d :: [Nat]) -> Generator -> Dynamic -> Dynamic -> IO Dynamic
- _exponential :: Dynamic -> Generator -> HsAccReal -> IO ()
- exponential :: Dims (d :: [Nat]) -> Generator -> HsAccReal -> IO Dynamic
- _standard_gamma :: Dynamic -> Generator -> Dynamic -> IO ()
- standard_gamma :: Dims (d :: [Nat]) -> Generator -> Dynamic -> IO Dynamic
- _cauchy :: Dynamic -> Generator -> HsAccReal -> HsAccReal -> IO ()
- cauchy :: Dims (d :: [Nat]) -> Generator -> HsAccReal -> HsAccReal -> IO Dynamic
- _logNormal :: Dynamic -> Generator -> HsAccReal -> Positive HsAccReal -> IO ()
- logNormal :: Dims (d :: [Nat]) -> Generator -> HsAccReal -> Positive HsAccReal -> IO Dynamic
- _multinomial :: LongDynamic -> Generator -> Dynamic -> Int -> Int -> IO ()
- _multinomialAliasSetup :: Dynamic -> LongDynamic -> Dynamic -> IO ()
- _multinomialAliasDraw :: LongDynamic -> Generator -> LongDynamic -> Dynamic -> IO ()
- data OpenUnit x
- openUnit :: (Ord x, Num x) => x -> Maybe (OpenUnit x)
- openUnitValue :: OpenUnit x -> x
- data ClosedUnit x
- closedUnit :: (Ord x, Num x) => x -> Maybe (ClosedUnit x)
- closedUnitValue :: ClosedUnit x -> x
- data Positive x
- positive :: (Ord x, Num x) => x -> Maybe (Positive x)
- positiveValue :: Positive x -> x
- data Ord2Tuple x
- ord2Tuple :: (Ord x, Num x) => (x, x) -> Maybe (Ord2Tuple x)
- ord2TupleValue :: Ord2Tuple x -> (x, x)
Documentation
random :: Dims (d :: [Nat]) -> Generator -> IO Dynamic Source #
Returns a tensor of specified size with random numbers from [1,2^mantissa].
_clampedRandom :: Integral a => Dynamic -> Generator -> Ord2Tuple a -> IO () Source #
call C-level clampedRandom
Arguments
:: Dims (d :: [Nat]) | size of tensor to create |
-> Generator | generator |
-> Ord2Tuple Integer | (minbound, maxBound) |
-> IO Dynamic |
Returns a tensor of specified size with random numbers from [minBound,maxBound]
.
Arguments
:: Dims (d :: [Nat]) | size of tensor to create |
-> Generator | generator |
-> Word64 | maxbound |
-> IO Dynamic |
Returns a tensor of specified size with random numbers from [0,maxBound]
.
Arguments
:: Dims (d :: [Nat]) | size of tensor to create |
-> Generator | generator |
-> OpenUnit HsAccReal |
|
-> IO Dynamic |
Returns a random tensor according to a geometric distribution
p(i) = (1-p) * p^(i-1)
. p
must satisfy 0 < p < 1
.
Arguments
:: Dims (d :: [Nat]) | size of tensor to create |
-> Generator | generator |
-> ClosedUnit HsAccReal |
|
-> IO Dynamic |
Returns a tensor filled with elements which are 1 with probability p
and
0 with probability 1-p
. p
must satisfy 0 <= p <= 1
.
_bernoulli_FloatTensor :: Dynamic -> Generator -> FloatDynamic -> IO () Source #
call C-level bernoulli_FloatTensor
bernoulli_FloatTensor Source #
Arguments
:: Dims (d :: [Nat]) | size of tensor to create |
-> Generator | generator |
-> FloatDynamic | float tensor of |
-> IO Dynamic |
Undocumented in Lua. It is assumed that this returns a tensor filled with
elements which are 1 with probability p
and 0 with probability 1-p
,
where p
comes from the FloatDynamic
tensor. All p
s must satisfy
0 <= p <= 1
. It is uncertain if the output dimensions and the
FloatDynamic
tensor dimensions need to match.
_bernoulli_DoubleTensor :: Dynamic -> Generator -> DoubleDynamic -> IO () Source #
call C-level bernoulli_DoubleTensor
bernoulli_DoubleTensor Source #
Arguments
:: Dims (d :: [Nat]) | size of tensor to create |
-> Generator | generator |
-> DoubleDynamic | double tensor of |
-> IO Dynamic |
Undocumented in Lua. It is assumed that this returns a tensor filled with
elements which are 1 with probability p
and 0 with probability 1-p
,
where p
comes from the DoubleDynamic
tensor. All p
s must satisfy
0 <= p <= 1
. It is uncertain if the output dimensions and the
DoubleDynamic
tensor dimensions need to match.
Arguments
:: Dims (d :: [Nat]) | size of tensor to create |
-> Generator | generator |
-> Ord2Tuple HsAccReal | tuple of |
-> IO Dynamic |
Returns a tensor filled with values according to uniform distribution on [a,b)
.
_normal :: Dynamic -> Generator -> HsAccReal -> Positive HsAccReal -> IO () Source #
call C-level normal
Arguments
:: Dims (d :: [Nat]) | size of tensor to create |
-> Generator | generator |
-> HsAccReal | mean |
-> Positive HsAccReal | standard deviation. |
-> IO Dynamic |
Returns a tensor filled with values according to a normal distribution with the given mean and standard deviation stdv. stdv must be positive.
_normal_means :: Dynamic -> Generator -> Dynamic -> Positive HsAccReal -> IO () Source #
call C-level normal_means
Arguments
:: Dims (d :: [Nat]) | size of tensor to create |
-> Generator | generator |
-> Dynamic | tensor of means |
-> Positive HsAccReal | standard deviation. |
-> IO Dynamic |
Same as normal
, taking a tensor of means to use instead of a scalar.
FIXME: It is uncertain if the output dimensions and mean tensor dimensions need to match.
_normal_stddevs :: Dynamic -> Generator -> HsAccReal -> Dynamic -> IO () Source #
call C-level normal_stddevs
Arguments
:: Dims (d :: [Nat]) | size of tensor to create |
-> Generator | generator |
-> HsAccReal | mean |
-> Dynamic | tensor of standard deviations |
-> IO Dynamic |
Same as normal
, taking a tensor of standard deviations to use instead of
a scalar. All standard deviations must be positive.
FIXME: It is uncertain if the output dimensions and stddv tensor dimensions need to match.
_normal_means_stddevs :: Dynamic -> Generator -> Dynamic -> Dynamic -> IO () Source #
call C-level normal_means_stddevs
Arguments
:: Dims (d :: [Nat]) | size of tensor to create |
-> Generator | generator |
-> Dynamic | tensor of means |
-> Dynamic | tensor of standard deviations |
-> IO Dynamic |
Same as normal
, taking a tensor of standard deviations and tensor of means
to use instead of a scalar values. All standard deviations must be positive.
FIXME: It is uncertain if all of the tensor dimensions need to match.
Arguments
:: Dims (d :: [Nat]) | size of tensor to create |
-> Generator | generator |
-> HsAccReal | lambda |
-> IO Dynamic |
Returns a tensor filled with values according to the exponential distribution
p(x) = lambda * exp(-lambda * x)
.
Draw samples from a standard Gamma distribution.
PyTorch's standard_gamma
function mostly references Numpy's. Documentation can be found here:
numpy.random.standard_gamma
I (stites) am not sure at the moment if the tensor argument is a tensor of parameters (in which case, can we replace it with something safer?), or a datasource.
FIXME(stites): This is an undocumented feature as far as I can tell. Someone should update this with a more thorough investigation.
Arguments
:: Dims (d :: [Nat]) | size of tensor to create |
-> Generator | generator |
-> HsAccReal | median |
-> HsAccReal | sigma |
-> IO Dynamic |
Returns a tensor filled with values according to the Cauchy distribution
p(x) = sigma/(pi*(sigma^2 + (x-median)^2))
_logNormal :: Dynamic -> Generator -> HsAccReal -> Positive HsAccReal -> IO () Source #
call C-level logNormal
Arguments
:: Dims (d :: [Nat]) | size of tensor to create |
-> Generator | generator |
-> HsAccReal | mean |
-> Positive HsAccReal | standard deviation. |
-> IO Dynamic |
Returns a tensor filled with values according to the log-normal distribution with the given mean and standard deviation stdv. mean and stdv are the corresponding mean and standard deviation of the underlying normal distribution, and not of the returned distribution.
stdv must be positive.
_multinomial :: LongDynamic -> Generator -> Dynamic -> Int -> Int -> IO () Source #
call C-level multinomial
_multinomialAliasSetup :: Dynamic -> LongDynamic -> Dynamic -> IO () Source #
call C-level multinomialAliasSetup
_multinomialAliasDraw :: LongDynamic -> Generator -> LongDynamic -> Dynamic -> IO () Source #
call C-level multinomialAliasDraw
Datatype to represent the open unit interval: 0 < x < 1
. Any OpenUnit
inhabitant
must satisfy being in the interval.
FIXME: replace with numhask.
Instances
Eq x => Eq (OpenUnit x) | |
Ord x => Ord (OpenUnit x) | |
Defined in Torch.Types.Numeric | |
Show x => Show (OpenUnit x) | |
openUnit :: (Ord x, Num x) => x -> Maybe (OpenUnit x) #
smart constructor to place a number in the open unit interval.
openUnitValue :: OpenUnit x -> x #
Get a value from the open unit interval.
data ClosedUnit x #
Datatype to represent the closed unit interval: 0 =< x =< 1
. Any ClosedUnit
inhabitant must satisfy being in the interval.
FIXME: replace with numhask.
Instances
Eq x => Eq (ClosedUnit x) | |
Defined in Torch.Types.Numeric | |
Ord x => Ord (ClosedUnit x) | |
Defined in Torch.Types.Numeric Methods compare :: ClosedUnit x -> ClosedUnit x -> Ordering # (<) :: ClosedUnit x -> ClosedUnit x -> Bool # (<=) :: ClosedUnit x -> ClosedUnit x -> Bool # (>) :: ClosedUnit x -> ClosedUnit x -> Bool # (>=) :: ClosedUnit x -> ClosedUnit x -> Bool # max :: ClosedUnit x -> ClosedUnit x -> ClosedUnit x # min :: ClosedUnit x -> ClosedUnit x -> ClosedUnit x # | |
Show x => Show (ClosedUnit x) | |
Defined in Torch.Types.Numeric Methods showsPrec :: Int -> ClosedUnit x -> ShowS # show :: ClosedUnit x -> String # showList :: [ClosedUnit x] -> ShowS # |
closedUnit :: (Ord x, Num x) => x -> Maybe (ClosedUnit x) #
smart constructor to place a number in the closed unit interval.
closedUnitValue :: ClosedUnit x -> x #
Get a value from the closed unit interval.
Datatype to represent a generic positive number: 0 =< x
.
FIXME: replace with numhask.
Instances
Eq x => Eq (Positive x) | |
Ord x => Ord (Positive x) | |
Defined in Torch.Types.Numeric | |
Show x => Show (Positive x) | |
positive :: (Ord x, Num x) => x -> Maybe (Positive x) #
smart constructor to place a number in a positive bound.
positiveValue :: Positive x -> x #
Get a value from the positive bound.
Datatype to represent an ordered pair of numbers, (a, b)
, where a <= b
.
FIXME: replace with numhask.
ord2Tuple :: (Ord x, Num x) => (x, x) -> Maybe (Ord2Tuple x) #
smart constructor to place two values in an ordered tuple.
ord2TupleValue :: Ord2Tuple x -> (x, x) #
Get the values of an ordered tuple.