{-# LANGUAGE RankNTypes #-}
module Mcmc.Proposal.Slide
( slide,
slideSymmetric,
slideUniformSymmetric,
slideContrarily,
)
where
import Mcmc.Proposal
import Mcmc.Proposal.Generic
import Mcmc.Statistics.Types
import Statistics.Distribution.Normal
import Statistics.Distribution.Uniform
slideSimple :: Mean Double -> StandardDeviation Double -> TuningParameter -> ProposalSimple Double
slideSimple :: Mean Double
-> Mean Double -> Mean Double -> ProposalSimple (Mean Double)
slideSimple Mean Double
m Mean Double
s Mean Double
t =
NormalDistribution
-> (Mean Double -> Mean Double -> Mean Double)
-> Maybe (Mean Double -> Mean Double)
-> Maybe (Mean Double -> Mean Double -> Jacobian)
-> ProposalSimple (Mean Double)
forall d a.
(ContDistr d, ContGen d) =>
d
-> (a -> Mean Double -> a)
-> Maybe (Mean Double -> Mean Double)
-> Maybe (a -> Mean Double -> Jacobian)
-> ProposalSimple a
genericContinuous (Mean Double -> Mean Double -> NormalDistribution
normalDistr Mean Double
m (Mean Double
s Mean Double -> Mean Double -> Mean Double
forall a. Num a => a -> a -> a
* Mean Double
t)) Mean Double -> Mean Double -> Mean Double
forall a. Num a => a -> a -> a
(+) ((Mean Double -> Mean Double) -> Maybe (Mean Double -> Mean Double)
forall a. a -> Maybe a
Just Mean Double -> Mean Double
forall a. Num a => a -> a
negate) Maybe (Mean Double -> Mean Double -> Jacobian)
forall a. Maybe a
Nothing
slide ::
Mean Double ->
StandardDeviation Double ->
PName ->
PWeight ->
Tune ->
Proposal Double
slide :: Mean Double
-> Mean Double
-> PName
-> PWeight
-> Tune
-> Proposal (Mean Double)
slide Mean Double
m Mean Double
s = PDescription
-> (Mean Double -> ProposalSimple (Mean Double))
-> PDimension
-> PName
-> PWeight
-> Tune
-> Proposal (Mean Double)
forall a.
PDescription
-> (Mean Double -> ProposalSimple a)
-> PDimension
-> PName
-> PWeight
-> Tune
-> Proposal a
createProposal PDescription
description (Mean Double
-> Mean Double -> Mean Double -> ProposalSimple (Mean Double)
slideSimple Mean Double
m Mean Double
s) (Int -> PDimension
PDimension Int
1)
where
description :: PDescription
description = String -> PDescription
PDescription (String -> PDescription) -> String -> PDescription
forall a b. (a -> b) -> a -> b
$ String
"Slide; mean: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Mean Double -> String
forall a. Show a => a -> String
show Mean Double
m String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", sd: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Mean Double -> String
forall a. Show a => a -> String
show Mean Double
s
slideSymmetricSimple :: StandardDeviation Double -> TuningParameter -> ProposalSimple Double
slideSymmetricSimple :: Mean Double -> Mean Double -> ProposalSimple (Mean Double)
slideSymmetricSimple Mean Double
s Mean Double
t =
NormalDistribution
-> (Mean Double -> Mean Double -> Mean Double)
-> Maybe (Mean Double -> Mean Double)
-> Maybe (Mean Double -> Mean Double -> Jacobian)
-> ProposalSimple (Mean Double)
forall d a.
(ContDistr d, ContGen d) =>
d
-> (a -> Mean Double -> a)
-> Maybe (Mean Double -> Mean Double)
-> Maybe (a -> Mean Double -> Jacobian)
-> ProposalSimple a
genericContinuous (Mean Double -> Mean Double -> NormalDistribution
normalDistr Mean Double
0.0 (Mean Double
s Mean Double -> Mean Double -> Mean Double
forall a. Num a => a -> a -> a
* Mean Double
t)) Mean Double -> Mean Double -> Mean Double
forall a. Num a => a -> a -> a
(+) Maybe (Mean Double -> Mean Double)
forall a. Maybe a
Nothing Maybe (Mean Double -> Mean Double -> Jacobian)
forall a. Maybe a
Nothing
slideSymmetric ::
StandardDeviation Double ->
PName ->
PWeight ->
Tune ->
Proposal Double
slideSymmetric :: Mean Double -> PName -> PWeight -> Tune -> Proposal (Mean Double)
slideSymmetric Mean Double
s = PDescription
-> (Mean Double -> ProposalSimple (Mean Double))
-> PDimension
-> PName
-> PWeight
-> Tune
-> Proposal (Mean Double)
forall a.
PDescription
-> (Mean Double -> ProposalSimple a)
-> PDimension
-> PName
-> PWeight
-> Tune
-> Proposal a
createProposal PDescription
description (Mean Double -> Mean Double -> ProposalSimple (Mean Double)
slideSymmetricSimple Mean Double
s) (Int -> PDimension
PDimension Int
1)
where
description :: PDescription
description = String -> PDescription
PDescription (String -> PDescription) -> String -> PDescription
forall a b. (a -> b) -> a -> b
$ String
"Slide symmetric; sd: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Mean Double -> String
forall a. Show a => a -> String
show Mean Double
s
slideUniformSimple :: Size -> TuningParameter -> ProposalSimple Double
slideUniformSimple :: Mean Double -> Mean Double -> ProposalSimple (Mean Double)
slideUniformSimple Mean Double
d Mean Double
t =
UniformDistribution
-> (Mean Double -> Mean Double -> Mean Double)
-> Maybe (Mean Double -> Mean Double)
-> Maybe (Mean Double -> Mean Double -> Jacobian)
-> ProposalSimple (Mean Double)
forall d a.
(ContDistr d, ContGen d) =>
d
-> (a -> Mean Double -> a)
-> Maybe (Mean Double -> Mean Double)
-> Maybe (a -> Mean Double -> Jacobian)
-> ProposalSimple a
genericContinuous (Mean Double -> Mean Double -> UniformDistribution
uniformDistr (-Mean Double
t Mean Double -> Mean Double -> Mean Double
forall a. Num a => a -> a -> a
* Mean Double
d) (Mean Double
t Mean Double -> Mean Double -> Mean Double
forall a. Num a => a -> a -> a
* Mean Double
d)) Mean Double -> Mean Double -> Mean Double
forall a. Num a => a -> a -> a
(+) Maybe (Mean Double -> Mean Double)
forall a. Maybe a
Nothing Maybe (Mean Double -> Mean Double -> Jacobian)
forall a. Maybe a
Nothing
slideUniformSymmetric ::
Size ->
PName ->
PWeight ->
Tune ->
Proposal Double
slideUniformSymmetric :: Mean Double -> PName -> PWeight -> Tune -> Proposal (Mean Double)
slideUniformSymmetric Mean Double
d = PDescription
-> (Mean Double -> ProposalSimple (Mean Double))
-> PDimension
-> PName
-> PWeight
-> Tune
-> Proposal (Mean Double)
forall a.
PDescription
-> (Mean Double -> ProposalSimple a)
-> PDimension
-> PName
-> PWeight
-> Tune
-> Proposal a
createProposal PDescription
description (Mean Double -> Mean Double -> ProposalSimple (Mean Double)
slideUniformSimple Mean Double
d) (Int -> PDimension
PDimension Int
1)
where
description :: PDescription
description = String -> PDescription
PDescription (String -> PDescription) -> String -> PDescription
forall a b. (a -> b) -> a -> b
$ String
"Slide uniform symmetric; delta: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Mean Double -> String
forall a. Show a => a -> String
show Mean Double
d
contra :: (Double, Double) -> Double -> (Double, Double)
contra :: (Mean Double, Mean Double)
-> Mean Double -> (Mean Double, Mean Double)
contra (Mean Double
x, Mean Double
y) Mean Double
u = (Mean Double
x Mean Double -> Mean Double -> Mean Double
forall a. Num a => a -> a -> a
+ Mean Double
u, Mean Double
y Mean Double -> Mean Double -> Mean Double
forall a. Num a => a -> a -> a
- Mean Double
u)
slideContrarilySimple ::
Mean Double ->
StandardDeviation Double ->
TuningParameter ->
ProposalSimple (Double, Double)
slideContrarilySimple :: Mean Double
-> Mean Double
-> Mean Double
-> ProposalSimple (Mean Double, Mean Double)
slideContrarilySimple Mean Double
m Mean Double
s Mean Double
t =
NormalDistribution
-> ((Mean Double, Mean Double)
-> Mean Double -> (Mean Double, Mean Double))
-> Maybe (Mean Double -> Mean Double)
-> Maybe ((Mean Double, Mean Double) -> Mean Double -> Jacobian)
-> ProposalSimple (Mean Double, Mean Double)
forall d a.
(ContDistr d, ContGen d) =>
d
-> (a -> Mean Double -> a)
-> Maybe (Mean Double -> Mean Double)
-> Maybe (a -> Mean Double -> Jacobian)
-> ProposalSimple a
genericContinuous (Mean Double -> Mean Double -> NormalDistribution
normalDistr Mean Double
m (Mean Double
s Mean Double -> Mean Double -> Mean Double
forall a. Num a => a -> a -> a
* Mean Double
t)) (Mean Double, Mean Double)
-> Mean Double -> (Mean Double, Mean Double)
contra ((Mean Double -> Mean Double) -> Maybe (Mean Double -> Mean Double)
forall a. a -> Maybe a
Just Mean Double -> Mean Double
forall a. Num a => a -> a
negate) Maybe ((Mean Double, Mean Double) -> Mean Double -> Jacobian)
forall a. Maybe a
Nothing
slideContrarily ::
Mean Double ->
StandardDeviation Double ->
PName ->
PWeight ->
Tune ->
Proposal (Double, Double)
slideContrarily :: Mean Double
-> Mean Double
-> PName
-> PWeight
-> Tune
-> Proposal (Mean Double, Mean Double)
slideContrarily Mean Double
m Mean Double
s = PDescription
-> (Mean Double -> ProposalSimple (Mean Double, Mean Double))
-> PDimension
-> PName
-> PWeight
-> Tune
-> Proposal (Mean Double, Mean Double)
forall a.
PDescription
-> (Mean Double -> ProposalSimple a)
-> PDimension
-> PName
-> PWeight
-> Tune
-> Proposal a
createProposal PDescription
description (Mean Double
-> Mean Double
-> Mean Double
-> ProposalSimple (Mean Double, Mean Double)
slideContrarilySimple Mean Double
m Mean Double
s) (Int -> PDimension
PDimension Int
2)
where
description :: PDescription
description = String -> PDescription
PDescription (String -> PDescription) -> String -> PDescription
forall a b. (a -> b) -> a -> b
$ String
"Slide contrarily; mean: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Mean Double -> String
forall a. Show a => a -> String
show Mean Double
m String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", sd: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Mean Double -> String
forall a. Show a => a -> String
show Mean Double
s