Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type MonteCarlo s a = MonteCarloT Identity s a
- type MonteCarloT m s = StateT s (RVarT m)
- runMC :: MonadRandom (StateT b Identity) => MonteCarlo s c -> b -> s -> c
- class Discretize a where
- initialize :: Discretize a => a -> Int -> MonteCarlo (Observables, Double) ()
- evolve :: Discretize a => a -> Double -> Bool -> MonteCarlo (Observables, Double) ()
- discounter :: Discretize a => a -> Double -> MonteCarlo (Observables, Double) (Vector Double)
- forwardGen :: Discretize a => a -> Double -> MonteCarlo (Observables, Double) (Vector Double)
- evolve' :: Discretize a => a -> Double -> Bool -> MonteCarlo (Observables, Double) ()
- maxStep :: Discretize a => a -> Double
- simulateState :: Discretize a => a -> ContingentClaimBasket -> Int -> Bool -> MonteCarlo (Observables, Double) Double
- runSimulation :: (Discretize a, MonadRandom (StateT b Identity)) => a -> ContingentClaim -> b -> Int -> Bool -> Double
- runSimulationAnti :: (Discretize a, MonadRandom (StateT b Identity)) => a -> ContingentClaim -> b -> Int -> Double
- quickSim :: Discretize a => a -> ContingentClaim -> Int -> Double
- quickSimAnti :: Discretize a => a -> ContingentClaim -> Int -> Double
- data OptionType
- getTrials :: MonteCarlo (Observables, Double) Int
The MonteCarlo type.
type MonteCarlo s a = MonteCarloT Identity s a Source
Wraps the Identity monad in the MonteCarloT
transformer.
type MonteCarloT m s = StateT s (RVarT m) Source
A monad transformer for Monte-Carlo calculations.
:: MonadRandom (StateT b Identity) | |
=> MonteCarlo s c | Monte Carlo computation. |
-> b | Initial state. |
-> s | Initial random-generator state. |
-> c | Final result of computation. |
Runs a MonteCarlo calculation and provides the result of the computation.
The discretize typeclass.
class Discretize a where Source
The Discretize
class defines those
models on which Monte Carlo simulations
can be performed.
Minimal complete definition: initialize
, discounter
, forwardGen
and evolve'
.
:: Discretize a | |
=> a | Model |
-> Int | number of trials |
-> MonteCarlo (Observables, Double) () |
Initializes a Monte Carlo simulation for a given number of runs.
:: Discretize a | |
=> a | Model |
-> Double | time to evolve to |
-> Bool | |
-> MonteCarlo (Observables, Double) () |
Evolves the internal states of the MC variables between two times.
discounter :: Discretize a => a -> Double -> MonteCarlo (Observables, Double) (Vector Double) Source
Stateful discounting function, takes a model and a time, and returns a vector of results.
forwardGen :: Discretize a => a -> Double -> MonteCarlo (Observables, Double) (Vector Double) Source
Stateful forward generator for a given model at a certain time.
:: Discretize a | |
=> a | model |
-> Double | time to evolve to |
-> Bool | whether or not to use flipped variates |
-> MonteCarlo (Observables, Double) () | computation result |
Internal function to evolve a model to a given time.
maxStep :: Discretize a => a -> Double Source
Determines the maximum size time-step for discretization purposes. Defaults to 1/250.
:: Discretize a | |
=> a | model |
-> ContingentClaimBasket | compilied basket of claims |
-> Int | number of trials |
-> Bool | antithetic? |
-> MonteCarlo (Observables, Double) Double | computation result |
Perform a simulation of a compiled basket of contingent claims.
:: (Discretize a, MonadRandom (StateT b Identity)) | |
=> a | model |
-> ContingentClaim | claims to value |
-> b | initial random state |
-> Int | trials |
-> Bool | whether to use antithetic variables |
-> Double | final value |
Runs a simulation for a ContingentClaim
.
runSimulationAnti :: (Discretize a, MonadRandom (StateT b Identity)) => a -> ContingentClaim -> b -> Int -> Double Source
Like runSimulation
, but splits the trials in two and does antithetic variates.
quickSim :: Discretize a => a -> ContingentClaim -> Int -> Double Source
runSimulation
with a default random number generator.
quickSimAnti :: Discretize a => a -> ContingentClaim -> Int -> Double Source
runSimulationAnti
with a default random number generator.
getTrials :: MonteCarlo (Observables, Double) Int Source
Utility function to get the number of trials.