rhine-bayes 0.9 → 1.0
raw patch · 4 files changed
+36/−20 lines, 4 filesdep ~rhinePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: rhine
API changes (from Hackage documentation)
+ FRP.Rhine.Bayes: type StochasticProcess time a = forall m. MonadDistribution m => Behaviour m time a
+ FRP.Rhine.Bayes: type StochasticProcessF time a b = forall m. MonadDistribution m => BehaviourF m time a b
+ FRP.Rhine.Bayes: whiteNoiseVarying :: StochasticProcessF td Double Double
- FRP.Rhine.Bayes: brownianMotionVarying :: (MonadDistribution m, Diff td ~ Double) => BehaviourF m td (Diff td) Double
+ FRP.Rhine.Bayes: brownianMotionVarying :: Diff td ~ Double => StochasticProcessF td (Diff td) Double
- FRP.Rhine.Bayes: whiteNoise :: MonadDistribution m => Double -> Behaviour m td Double
+ FRP.Rhine.Bayes: whiteNoise :: Double -> StochasticProcess td Double
- FRP.Rhine.Bayes: wienerLogDomain :: (MonadDistribution m, Diff td ~ Double) => Diff td -> Behaviour m td (Log Double)
+ FRP.Rhine.Bayes: wienerLogDomain :: Diff td ~ Double => Diff td -> StochasticProcess td (Log Double)
- FRP.Rhine.Bayes: wienerVarying :: (MonadDistribution m, Diff td ~ Double) => BehaviourF m td (Diff td) Double
+ FRP.Rhine.Bayes: wienerVarying :: Diff td ~ Double => StochasticProcessF td (Diff td) Double
- FRP.Rhine.Bayes: wienerVaryingLogDomain :: (MonadDistribution m, Diff td ~ Double) => BehaviourF m td (Diff td) (Log Double)
+ FRP.Rhine.Bayes: wienerVaryingLogDomain :: Diff td ~ Double => StochasticProcessF td (Diff td) (Log Double)
Files
- ChangeLog.md +6/−0
- app/Main.hs +10/−10
- rhine-bayes.cabal +3/−3
- src/FRP/Rhine/Bayes.hs +17/−7
ChangeLog.md view
@@ -1,5 +1,11 @@ # Revision history for rhine-gloss +## 1.0++* Removed schedules. See the [page about changes in version 1](/version1.md).+* Introduced type alias `StochasticProcess`.+* Added `whiteNoiseVarying`.+ ## 0.9 * Add simple Poisson, Gamma and Bernoulli processes
app/Main.hs view
@@ -59,14 +59,14 @@ -- | Harmonic oscillator with white noise prior1d ::- (MonadDistribution m, Diff td ~ Double) =>+ (Diff td ~ Double) => -- | Starting position Double -> -- | Starting velocity Double ->- BehaviourF m td Temperature Double+ StochasticProcessF td Temperature Double prior1d initialPosition initialVelocity = feedback 0 $ proc (temperature, position') -> do- impulse <- arrM (normal 0) -< temperature+ impulse <- whiteNoiseVarying -< temperature let acceleration = (-3) * position' + impulse -- Integral over roughly the last 100 seconds, dying off exponentially, as to model a small friction term velocity <- arr (+ initialVelocity) <<< decayIntegral 10 -< acceleration@@ -88,11 +88,11 @@ sensorNoiseTemperature = 1 -- | A generative model of the sensor noise-noise :: MonadDistribution m => Behaviour m td Pos+noise :: StochasticProcess td Pos noise = whiteNoise sensorNoiseTemperature &&& whiteNoise sensorNoiseTemperature -- | A generative model of the sensor position, given the noise-generativeModel :: (MonadDistribution m, Diff td ~ Double) => BehaviourF m td Pos Sensor+generativeModel :: (Diff td ~ Double) => StochasticProcessF td Pos Sensor generativeModel = proc latent -> do noiseNow <- noise -< () returnA -< latent ^+^ noiseNow@@ -286,7 +286,7 @@ mainSingleRate = void $ sampleIO $- launchGlossThread glossSettings $+ launchInGlossThread glossSettings $ reactimateCl glossClock mainClSF -- ** Multi-rate: Simulation, inference, display at different rates@@ -337,18 +337,18 @@ mainRhineMultiRate = userTemperature @@ glossClockUTC GlossEventClockIO- >-- keepLast initialTemperature -@- glossConcurrently -->+ >-- keepLast initialTemperature --> modelRhine- >-- keepLast (initialTemperature, (zeroVector, zeroVector)) -@- glossConcurrently -->+ >-- keepLast (initialTemperature, (zeroVector, zeroVector)) --> inference- >-- keepLast Result {temperature = initialTemperature, measured = zeroVector, latent = zeroVector, particles = []} -@- glossConcurrently -->+ >-- keepLast Result {temperature = initialTemperature, measured = zeroVector, latent = zeroVector, particles = []} --> visualisationRhine {- FOURMOLU_ENABLE -} mainMultiRate :: IO () mainMultiRate = void $- launchGlossThread glossSettings $+ launchInGlossThread glossSettings $ flow mainRhineMultiRate -- * Utilities
rhine-bayes.cabal view
@@ -1,5 +1,5 @@ name: rhine-bayes-version: 0.9+version: 1.0 synopsis: monad-bayes backend for Rhine description: This package provides a backend to the `monad-bayes` library,@@ -23,7 +23,7 @@ source-repository this type: git location: git@github.com:turion/rhine.git- tag: v0.9+ tag: v1.0 library exposed-modules:@@ -32,7 +32,7 @@ Data.MonadicStreamFunction.Bayes build-depends: base >= 4.11 && < 4.18 , transformers >= 0.5- , rhine == 0.9+ , rhine == 1.0 , dunai ^>= 0.9 , log-domain >= 0.12 , monad-bayes >= 1.1.0
src/FRP/Rhine/Bayes.hs view
@@ -39,10 +39,20 @@ -- * Short standard library of stochastic processes +-- | A stochastic process is a behaviour that uses, as only effect, random sampling.+type StochasticProcess time a = forall m. MonadDistribution m => Behaviour m time a++-- | Like 'StochasticProcess', but with a live input.+type StochasticProcessF time a b = forall m. MonadDistribution m => BehaviourF m time a b+ -- | White noise, that is, an independent normal distribution at every time step.-whiteNoise :: MonadDistribution m => Double -> Behaviour m td Double+whiteNoise :: Double -> StochasticProcess td Double whiteNoise sigma = constMCl $ normal 0 sigma +-- | Like 'whiteNoise', that is, an independent normal distribution at every time step.+whiteNoiseVarying :: StochasticProcessF td Double Double+whiteNoiseVarying = arrMCl $ normal 0+ -- | Construct a Lévy process from the increment between time steps. levy :: (MonadDistribution m, VectorSpace v (Diff td)) =>@@ -64,8 +74,8 @@ -- | The Wiener process, also known as Brownian motion, with varying variance parameter. wienerVarying , brownianMotionVarying ::- (MonadDistribution m, Diff td ~ Double) =>- BehaviourF m td (Diff td) Double+ (Diff td ~ Double) =>+ StochasticProcessF td (Diff td) Double wienerVarying = proc timeScale -> do diffTime <- sinceLastS -< () let stdDev = sqrt $ diffTime / timeScale@@ -78,16 +88,16 @@ -- | The 'wiener' process transformed to the Log domain, also called the geometric Wiener process. wienerLogDomain ::- (MonadDistribution m, Diff td ~ Double) =>+ (Diff td ~ Double) => -- | Time scale of variance Diff td ->- Behaviour m td (Log Double)+ StochasticProcess td (Log Double) wienerLogDomain timescale = wiener timescale >>> arr Exp -- | See 'wienerLogDomain' and 'wienerVarying'. wienerVaryingLogDomain ::- (MonadDistribution m, Diff td ~ Double) =>- BehaviourF m td (Diff td) (Log Double)+ (Diff td ~ Double) =>+ StochasticProcessF td (Diff td) (Log Double) wienerVaryingLogDomain = wienerVarying >>> arr Exp {- | Inhomogeneous Poisson point process, as described in: