Created
October 22, 2015 20:43
-
-
Save sivawashere/f4bd3a0ed4f2832264ae to your computer and use it in GitHub Desktop.
Steady state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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