Skip to content

Instantly share code, notes, and snippets.

@sivawashere
Created October 22, 2015 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sivawashere/f4bd3a0ed4f2832264ae to your computer and use it in GitHub Desktop.
Save sivawashere/f4bd3a0ed4f2832264ae to your computer and use it in GitHub Desktop.
Steady state
{-# LANGUAGE RecordWildCards #-}
import Data.Ratio
import Linear.Matrix
import Linear.V3
import Linear.Epsilon
import Control.Monad.Fix
type State = V3 Double
data System = System {
x0 :: State,
a :: M33 Double
}
(===) :: State -> State -> Bool
a === b = nearZero $ a - b
steadyState :: System -> State
steadyState System{..} = fix t x0 where
t rec xk = let xk1 = a !* xk in
if xk === xk1 then
xk
else
rec xk1
dtmc = System {
x0 = V3 1 0 0,
a = V3 (V3 0.5 0.2 0.3)
(V3 0.3 0.8 0.3)
(V3 0.2 0.0 0.4)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment