hasktorch-0.0.1.0: Torch for tensors and neural networks in Haskell

Copyright(c) Sam Stites 2017
LicenseBSD3
Maintainersam@stites.io
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Torch.Core.Random

Description

Random number generation for single values. FFI over TH/THRandom.h

Synopsis

Documentation

data Generator #

Representation of a CPU-bound random number generator

Instances
Eq Generator 
Instance details

Defined in Torch.Types.TH

Show Generator 
Instance details

Defined in Torch.Types.TH

data Seed #

Representation of a CPU-bound random seed

Instances
Bounded Seed 
Instance details

Defined in Torch.Types.TH

Enum Seed 
Instance details

Defined in Torch.Types.TH

Methods

succ :: Seed -> Seed #

pred :: Seed -> Seed #

toEnum :: Int -> Seed #

fromEnum :: Seed -> Int #

enumFrom :: Seed -> [Seed] #

enumFromThen :: Seed -> Seed -> [Seed] #

enumFromTo :: Seed -> Seed -> [Seed] #

enumFromThenTo :: Seed -> Seed -> Seed -> [Seed] #

Eq Seed 
Instance details

Defined in Torch.Types.TH

Methods

(==) :: Seed -> Seed -> Bool #

(/=) :: Seed -> Seed -> Bool #

Integral Seed 
Instance details

Defined in Torch.Types.TH

Methods

quot :: Seed -> Seed -> Seed #

rem :: Seed -> Seed -> Seed #

div :: Seed -> Seed -> Seed #

mod :: Seed -> Seed -> Seed #

quotRem :: Seed -> Seed -> (Seed, Seed) #

divMod :: Seed -> Seed -> (Seed, Seed) #

toInteger :: Seed -> Integer #

Num Seed 
Instance details

Defined in Torch.Types.TH

Methods

(+) :: Seed -> Seed -> Seed #

(-) :: Seed -> Seed -> Seed #

(*) :: Seed -> Seed -> Seed #

negate :: Seed -> Seed #

abs :: Seed -> Seed #

signum :: Seed -> Seed #

fromInteger :: Integer -> Seed #

Ord Seed 
Instance details

Defined in Torch.Types.TH

Methods

compare :: Seed -> Seed -> Ordering #

(<) :: Seed -> Seed -> Bool #

(<=) :: Seed -> Seed -> Bool #

(>) :: Seed -> Seed -> Bool #

(>=) :: Seed -> Seed -> Bool #

max :: Seed -> Seed -> Seed #

min :: Seed -> Seed -> Seed #

Read Seed 
Instance details

Defined in Torch.Types.TH

Real Seed 
Instance details

Defined in Torch.Types.TH

Methods

toRational :: Seed -> Rational #

Show Seed 
Instance details

Defined in Torch.Types.TH

Methods

showsPrec :: Int -> Seed -> ShowS #

show :: Seed -> String #

showList :: [Seed] -> ShowS #

newRNG :: IO Generator Source #

Construct a new Generator

copy :: Generator -> Generator -> IO Generator Source #

Copy a Generator state to a new generator

seed :: Generator -> IO Seed Source #

Get the current Seed of a Generator

manualSeed :: Generator -> Seed -> IO () Source #

Manually set the seed Seed of a Generator

initialSeed :: Generator -> IO Seed Source #

Get the first Seed that initialized a given Generator

uniform Source #

Arguments

:: Generator 
-> Double

lower bound

-> Double

upper bound

-> IO Double 

Returns a random double according to uniform distribution on [a,b).

uniformFloat Source #

Arguments

:: Generator 
-> Float

lower bound

-> Float

upper bound

-> IO Float 

Returns a random float according to uniform distribution on [a,b).

normal Source #

Arguments

:: Generator 
-> Double

mean

-> Double

stddev (must be positive)

-> IO Double 

Returns a random real number according to a normal distribution with the given mean and standard deviation stdv. stdv must be positive, but this is not yet enforced.

TODO: add a newtype Pos a = Pos { getPos :: a } package with a smart constructor export

exponential :: Generator -> Double -> IO Double Source #

Returns a random real number according to the exponential distribution p(x) = lambda * exp(-lambda * x)

cauchy Source #

Arguments

:: Generator 
-> Double

median

-> Double

sigma

-> IO Double 

Returns a random real number according to the Cauchy distribution p(x) = sigma/(pi*(sigma^2 + (x-median)^2))

logNormal Source #

Arguments

:: Generator 
-> Double

mean

-> Double

stddev (must be positive)

-> IO Double 

Returns a random real number 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.

geometric :: Generator -> Double -> IO Int Source #

Returns a random integer number according to a geometric distribution p(i) = (1-p) * p^(i-1). p must satisfy 0 < p < 1.

bernoulli :: Generator -> Double -> IO Int Source #

Returns 1 with probability p and 0 with probability 1-p. p must satisfy 0 <= p <= 1.

TODO: By default p is equal to 0.5 -- this isn't encoded in the API