Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type M = Matrix Double
- type V = Vector Double
- (.*) :: M -> M -> M
- (./) :: M -> M -> M
- (.-) :: M -> M -> M
- (^*) :: Double -> M -> M
- norm_1 :: M -> Double
- norm_F :: M -> Double
- fundamental :: M -> M
- occVariance :: M -> M
- perron :: M -> V
- sigma :: M -> V -> V
- nodeProbabilities :: M -> M
- expectedLength :: M -> Double
- expectedArcReliability :: Maybe (M, M) -> (M, M) -> (M, M)
- transientReliability :: M -> Maybe (M, M) -> (M, M) -> (M, M)
- singleUseReliability :: M -> Maybe (M, M) -> (M, M) -> (Double, Double)
- kullbackLeibler :: M -> M -> V -> M -> Double
Documentation
The fundamental matrix for absorbing chains. Its (i, j)-th entry is the expected number of occurrences of state j prior to absorption at the sink, given that one starts in state i. So the first row indicates the expected occurence of each state starting from the start state.
>>>
fundamental (minorMatrix 5 5 p :: M)
┌ ┐ │ 1.0 1.2307692307692306 1.2307692307692308 0.9230769230769231 │ │ 0.0 1.2307692307692306 1.2307692307692308 0.9230769230769231 │ │ 0.0 0.15384615384615385 2.1538461538461537 0.6153846153846154 │ │ 0.0 0.3076923076923077 0.3076923076923077 1.2307692307692308 │ └ ┘
Expected variance of the occurrence for each state. The (i, j)-th entry should be read in the same away as that of the fundamental matrix above.
>>>
occVariance (fundamental (minorMatrix 5 5 p :: M))
┌ ┐ │ 0.0 0.28402366863905315 2.5562130177514795 0.4970414201183433 │ │ 0.0 0.28402366863905315 2.5562130177514795 0.4970414201183433 │ │ 0.0 0.20118343195266267 2.4852071005917153 0.5207100591715977 │ │ 0.0 0.3550295857988165 0.9230769230769231 0.2840236686390534 │ └ ┘
The Perron eigenvector (long-run occupancies/probabilities of states).
>>>
perron p
[0.1857142857142857,0.22857142857142854,0.22857142857142856,0.17142857142857143,0.1857142857142857]
Compute the stimulus long-run occupancy.
>>>
:{
let s :: M s = fromList 4 5 [ 1, 0, 0, 0, 0 , 0, 0.5, 0.5, 0, 0 , 0, 0.5, 0.25, 0.25, 0 , 0.25, 0, 0, 0.5, 0.25 ] in sigma s (perron p) :} [0.2807017543859649,0.2807017543859649,0.21052631578947367,0.17543859649122806,5.2631578947368425e-2]
Compute the probability of occurrence for each state.
>>>
getRow 1 (nodeProbabilities p)
[1.0,1.0,0.5714285714285715,0.75]
Expected test case length.
>>>
expectedLength (fundamental (minorMatrix 5 5 p :: M))
4.384615384615385
expectedArcReliability Source #
Success rate matrix.
>>>
expectedArcReliability Nothing (fromList 2 2 [10,10,10,10], fromList 2 2 [0,1,2,3])
(┌ ┐ │ 0.9166666666666666 0.8461538461538461 │ │ 0.7857142857142857 0.7333333333333333 │ └ ┘,┌ ┐ │ 5.876068376068376e-3 9.298393913778529e-3 │ │ 1.1224489795918367e-2 1.2222222222222223e-2 │ └ ┘)>>>
:{
expectedArcReliability (Just (fromList 2 2 [10,10,10,10], fromList 2 2 [1,1,1,1])) (fromList 2 2 [10,10,10,10], fromList 2 2 [0,1,2,3]) :} (┌ ┐ │ 0.9130434782608695 0.875 │ │ 0.84 0.8076923076923077 │ └ ┘,┌ ┐ │ 3.3081285444234404e-3 4.375e-3 │ │ 5.169230769230769e-3 5.752794214332676e-3 │ └ ┘)
:: M | Transitions (n x n). |
-> M | Stimulis (m x n). |
-> V | State visitations (n). |
-> M | Stimulus execution (m x n). |
-> Double | Discrimination. |
Kullback-Leibler matrix discrimination.
>>>
:{
let s = fromList 4 5 [ 1, 0, 0, 0, 0 , 0, 0.5, 0.5, 0, 0 , 0, 0.5, 0.25, 0.25, 0 , 0.25, 0, 0, 0.5, 0.25 ] es = Vector.fromList [4, 5, 7, 3, 4] et = fromList 4 5 [ 4, 0, 0, 0, 0 , 0, 3, 2, 0, 0 , 0, 4, 1, 2, 0 , 1, 0, 0, 1, 1 ] in kullbackLeibler p s es et :} 3.440540391434413e-2